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
Define aop(assepct oriented programing)?
how to use debug in my elipse to solve problems that exist in my project
Name the class that is used to bind the server object with RMI Registry?
What is the relationship between the canvas class and the graphics class?
What is scalable, portability in the view of J2EE?
What are callback interfaces?
In RMI, inorder to sent the stub reference to the client, is we have to load the server object first into the memory or can we directly sent reference to the client?
What state does a thread enter when it terminates its processing?
What is abstract schema?
Can we sent objects using Sockets?
How a component can be placed on Windows?
Can I use multiple html form elements with the same name?
Where can I ask questions and make suggestions about seam?
Explain the different types of memory used by jvm?
What are the sequence of steps to write pub or sub model kind of application?