Write a java program to find out the sum of harmonic series :
1 + ½ + 1/3 + ……… up to nth term , for any value of n.
Answer Posted / sourav dey
import java.io.*;
class Hermonic{
public static void main(String args[]){
BufferedReader in=new BufferedReader(new
InputStreamReader(System.in));
double result = 0.0;
int num=0;
try{
System.out.println("Enter a term which you want to sum:");
num = Integer.parseInt(in.readLine());
}
catch(Exception e){}
while(num > 0){
result = result +( (double) 1 / num);
num--;
}
System.out.println("Output of Harmonic Series is "+result);
}
}
| Is This Answer Correct ? | 12 Yes | 0 No |
Post New Answer View All Answers
the same information whether it will connect to the database or it will be used previous information?
What are various types of class loaders used by jvm?
Will the general public have access to the infobus apis?
Name three component subclasses that support painting?
What is ioc concept & explain it?
Which characters may be used as the second character of an identifier, but not as the first character of an identifier?
What is abstract schema?
Why use a datasource when you can directly specify a connection details? (in a J2EE application)
What is table mutation and how do you avoid it?
What is the difference between long.class and long.type?
Define aop(assepct oriented programing)?
Are enterprise beans allowed to use thread.sleep()?
Why use a datasource when you can directly specify a connection details?
Is it possible to stop the execution of a method before completion in a sessionbean?
Where can I ask questions and make suggestions about seam?