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
Social Sciences,
5 months ago
English,
5 months ago
India Languages,
10 months ago
English,
10 months ago
Biology,
1 year ago