How To Write A Java Program To Determine The Sum Of The Following Harmonic Series For A Given Value Of N 1+1/2+1/3......1/n?

3

3 Answers

Anonymous Profile
Anonymous answered
Class HarmonicSeries{
  public static void main(String args[]){
  int num = Integer.parseInt(args[0]);
  double result = 0.0;
  while(num > 0){
  result = result + (double) 1 / num;
  num--;
  }
  System.out.printl of Harmonic Series is "+result);
  }
}
Anonymous Profile
Anonymous answered
Class harmonic
{
public static void main(String args[])
{
int n=Integer.parseInt(args[0]); //command line argument
double ans=0;
for(int I=1;I

Answer Question

Anonymous