Computer Science, asked by rajeswaripurohit1, 10 months ago

write a program to find the sum of the following series S = 1/a + 2/a² + 3/a³ + . . . . . . . . . . . . to n​

Answers

Answered by nupur3930
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