wap to find the sum of series given :A1/1 +A2/4+A3/9+A4/16+.................... n terms
Answers
Answered by
1
Answer:
// Java program to find the sum of the given series
import java.util.Scanner;
public class HelloWorld {
// Function to return the sum of the series
public static float getSum(int a, int n)
{
// variable to store the answer
float sum = 0;
for (int i = 1; i <= n; ++i) {
// Math.pow(x, y) returns x^y
sum += (i / Math.pow(a, i));
}
return sum;
}
// Driver code
public static void main(String[] args)
{
int a = 3, n = 3;
// Print the sum of the series
System.out.println(getSum(a, n));
}
}
Similar questions
Social Sciences,
2 months ago
Math,
2 months ago
English,
2 months ago
Math,
4 months ago
Environmental Sciences,
10 months ago
History,
10 months ago
English,
10 months ago