Computer Science, asked by sabitayadav524, 5 months ago

s=1/x+3/x²+5/x³+7/x⁴ .....n in Java​

Answers

Answered by sakshibital
0

Answer:

C++ implementatio to find

// sum of series of

// 1 + x^2 + x^3 + ....+ x^n

#include <bits/stdc++.h>

using namespace std;

// Function to find the sum of

// the series and print N terms

// of the given series

double sum(int x, int n)

{

double i, total = 1.0, multi = x;

// First Term

cout << total << " ";

// Loop to print the N terms

// of the series and find their sum

for (i = 1; i < n; i++) {

total = total + multi;

cout << multi << " ";

multi = multi * x;

}

cout << "\n";

return total;

}

// Driver code

int main()

{

int x = 2;

int n = 5;

cout << fixed

<< setprecision(2)

<< sum(x, n);

return 0;

}

Similar questions