Computer Science, asked by augku453, 7 months ago

Pls answer this question !!! I'll mark as brainlist
No spam pls!!!
Write a program in Java to find the sum of given series
1+(2^2)/a+(3^3)/(a*a).......................................................to n terms

Answers

Answered by ShezaFathima
1

Explanation:

public static void main(String[] args) {

Scanner scn=new Scanner(System.in);

int n=scn.nextInt(), sum=0;

for(int i=1; i<=n; i++) sum+=fact(i);

System.out.println(sum);

}

Answered by Anonymous
5

Answer:

$import \: java.util.^* \: ;$

class \: printing

 \{

public \: static \: void \: main \: (String  \: args[ \: ] \: )

 \{

Scanner \: sc \: = \: new  \: Scanner \: ( \: System.in \: );

int \:  i \: , \: n \: , \: sum \: ;

System.out.println("Please  \: enter  \: the \:  value \:  of  \: n");

n \: = \: sc.nextInt();

System.out.println("Please \:  enter \:  the  \: value \: of \: a");

a \: = \: sc.nextInt();

for(i=1;i &lt; = n;i++)

 \{

sum \: = \: sum \: + \: (Math.pow(i,i)/Math.pow(a,(i-1)));

 \}

System.out.println("Sum\:of\:the\:series\:=\:"+sum);

 \}

 \}

Explanation:

The logic was very simple. You have to just do this:

$\dfrac{i^i}{a^(i-1)}$ until n terms

So, you have to just take the value of n and a from the user and substitute value a and n in the place of a and n in the program.

Similar questions