Computer Science, asked by Rainbowgain, 3 months ago

Write a program to find the series ​

Attachments:

Answers

Answered by BrainlyProgrammer
13

Question:-

  • WAP to find the sum of the series.

s =  \dfrac{ {a}^{1} }{1}  +  \dfrac{ {a}^{2} }{2}  + ... .. +  \dfrac{ {a}^{10} }{10}

Logic:-

  • s=a^ i/i //where i is a loop variable.

Answer:-

//Java program to find the sum of the series

package Programmer;

import java.util. *;

public class Series{

public static void main (String ar []){

Scanner sc=new Scanner(System. in);

System.out.println("Enter value of 'a'");

int a=sc.nextInt();

int s=0;

for(int I=1;I<=10;I++)

s + =Math.pow(a,I)/I;

System.out.println("Sum="+s);

}

}

____

Variable Description:-

  • a:- Local Variable
  • s:- to calculate sum
  • I:- loop variable

___

Answered by Anisha5119
6

Explanation:

import java.util.*;

class Series22

{

public static void main ()

{

Scanner sc=new Scanner(System.in)

{

int s=0;

System.out.println("Enter value of a');

a=sc.nextInt();

int s=0;

for(int i=1;I<=10;i++)

s=s+Math.pow(a,i)/1;

System.out.println("Sum= "+s);

}

}

Similar questions