Write a program to find the series
Attachments:
Answers
Answered by
13
Question:-
- WAP to find the sum of the series.
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
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