s=1/2+2/3+3/4+......n terms computer program in java
pls help
Answers
Answered by
2
Correct Question:-
Write a program in Java to find the sum of the series.
S = 1/2 + 2/3 + 3/4+....
Program:-
import java.util.*;
class Sum
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
int i,n;
double s=0.0;
System.out.print("Enter the value of n: ");
n=sc.nextInt();
for(i=1;i<=n;i++)
s=s+i/(double)(i+1);
System.out.println("Sum of the series is: "+s);
}
}
Similar questions
History,
6 months ago
English,
6 months ago
India Languages,
11 months ago
English,
11 months ago
Biology,
1 year ago