Java

Calculate The Serious of Number Program Using Java

Calculate The Serious of Number Program Using Java
// series of number program 

import java.io.*; 
import java.lang.*; 

public class ssva01 

{ 
public static void main(String arg[]) throws IOException 
{ 
float n,i; 
float a; 
BufferedReader inp=new BufferedReader(new InputStreamReader(System.in)); 
System.out.print("\n\nEnter the value of N: "); 
n=Float.parseFloat(inp.readLine()); 
a=0; 
for(i=1;i<=n;i++) 
{ 
a=a+(1/i); 
} 
System.out.println("Series of numbers: "+a); 
} 
}
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.