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
Where can I ask questions and make suggestions about seam?
Name three subclasses of the component class?
Difference between DurableSubscription and non- DurableSubscription?
Is jvm a overhead?
What are the different approaches to represent an inheritance hierarchy?
What are the different class loaders used by jvm?
Explain how will the struts know which action class to call when you submit a form?
Explain RMI Architecture?
What is aop(assepct oriented programing)?
Explain what is orm?
Where we can write Rmi registry in the code, without having to write it at the command prompt?
What is the purpose of the finally clause of a try-catch-finally statement?
What is Stream Tokenizer?
What is the difference between the session.update() method and the session.lock() method?
What is RMI and what are the services in RMI?