EDUTAINMENT
EDUCATION + ENTERTAINMENT = EDUTAINMENT
Pages
Home
C Programs
C++Programs
Java Programs
Data Structures
Python Programs
HTML Programs
Download Books
GATE PAPERS
Auto AdSense
Saturday, 22 November 2014
Java Program to Generate Harmonic Series
class HarmonicSeries
{
public static void main(String args[])
{
int num = Integer.parseInt(args[0]);
double result = 0.0;
while(num > 0)
{
result = result + (double) 1 / num;
num--;
}
System.out.println("Output of Harmonic Series is "+result);
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment