write a program to find the sum of the following series S = 1/a + 2/a² + 3/a³ + . . . . . . . . . . . . to n
Answers
Answered by
2
Answer:
import java.util.Scanner;
class sum
{
public static void main (String argss[])
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter the value of n");
int n = sc.nextInt();
System.out.println("Enter the value of a");
int a = sc.nextInt();
int sum=0;
for (int x=1 ; x<=n ; x++)
{
sum = sum + x/Math.pow(a,x);
}
System.out.println(sum);
}
}
Similar questions
Political Science,
4 months ago
Biology,
4 months ago
Math,
9 months ago
Business Studies,
1 year ago