Computer Science, asked by brainological, 10 months ago

s=1/2+2/3+3/4+......n terms computer program in java
pls help​

Answers

Answered by anindyaadhikari13
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