title: Write a Program that calculates the sum of (a/1)+(a/2)+(a/3)+(a/4)+..........+(a/n)
body: <p>I'm trying to solve this program its to Print the sum of: (a/1)+(a/2)+(a/3)+(a/4)+..........+(a/n)
  where a is inputed by the user and the limit for n is also inputed by the user this is the program i tried:</p>
  
  <pre><code>/**
   * Program to 
   * 
   * Anirudh Gupta
   * th August 2014
   */
  import java.io.*;
  public class Program87b
  {
     public static void main () throws IOException
     {
         InputStreamReader isr=new InputStreamReader(System.in);
         BufferedReader br= new BufferedReader(isr);
         System.out.println("Enter the value of the numerator");
         double a=Double.parseDouble(br.readLine());
         System.out.println("Enter the limit for the denominator");
         int limit=Integer.parseInt(br.readLine());
         double n=1.0;
         double sum=0.0;
         while(n&lt;=limit)
         {
             sum=+(a/n);
             n++;
         }
         System.out.println(sum);
     }
  }
  </code></pre>
  
  <p>but when i enter a=4 and n=5 i get 0.8 which is just the ans of (4/5) and not the sum of (4/1)+(4/2)+(4/3)+(4/4)+(4/5) which should be 9.1333333333...</p>