Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the difference between RMI registry and OS Agent?

1147


How to implement dphibernate to activate lazy loading in Flex with java ?thanx in advance!

3008


wahts is mean by dynavalidatorform in struts/

2080


What are the design considerations while making a choice between using interface and abstract class?

1097


difference between  ejb,struts,hibernate,spring and jsp

2873


What are the pros and cons of detached objects?

984


which book is better for jdbc ,servlets and jsp

2106


How many times may an objects finalize() method be invoked by the garbage collector?

1091


What are the different types of exception?

1037


In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?

2675


How task's priority is used in scheduling?

2300


Name the class that is used to bind the server object with RMI Registry?

2170


we use MainFrame and using os390 for operating system with DB2 data base in IRAN and interest programing with java and use webspere for world wide,please help me where i should start?

2422


How substring() method of string class create memory leaks?

1046


Name three subclasses of the component class?

1111