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
Hindi,
5 months ago
Social Sciences,
5 months ago
English,
5 months ago
Math,
10 months ago
Business Studies,
1 year ago