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

Where can I ask questions and make suggestions about seam?

1112


Name three subclasses of the component class?

1159


Difference between DurableSubscription and non- DurableSubscription?

2234


Is jvm a overhead?

1162


What are the different approaches to represent an inheritance hierarchy?

1115


What are the different class loaders used by jvm?

1149


Explain how will the struts know which action class to call when you submit a form?

1013


Explain RMI Architecture?

1153


What is aop(assepct oriented programing)?

1120


Explain what is orm?

1151


Where we can write Rmi registry in the code, without having to write it at the command prompt?

2831


What is the purpose of the finally clause of a try-catch-finally statement?

1076


What is Stream Tokenizer?

2322


What is the difference between the session.update() method and the session.lock() method?

1082


What is RMI and what are the services in RMI?

1248