To find the sum of the series X=1+1/2+1/3+—+1/10


//Write a program in java to find the sum of the series.

//X=1+1/2+1/3+————+1/10

import java.io.*;
public class ser1
{
public static void main(String aa[])
{
int a;
float x;
x=0;
for(a=1;a<=10;a++)
{
x=x+1/a;
}
System.out.println(“Sum of the series=”+x);
}
}

output:

Related Posts

Comments are closed.