Summation Listing

class Summation1{
public static void main (String [] args) {
double sum,n;
sum = 0;
for (n = 1.0; n <= 25.0; n++)
{sum = sum + 1/n;

System.out.println(" The sum of 1/"+n+" and the previous sum is "+ sum);
}
}
}

Result

Find the sum of 1/1 + 1/2 + 1/3 + ..........................  1/25
The sum of 1/1.0 and the previous sum is 1.0
The sum of 1/2.0 and the previous sum is 1.5
The sum of 1/3.0 and the previous sum is 1.8333333333333333
The sum of 1/4.0 and the previous sum is 2.083333333333333
The sum of 1/5.0 and the previous sum is 2.283333333333333
The sum of 1/6.0 and the previous sum is 2.4499999999999997
The sum of 1/7.0 and the previous sum is 2.5928571428571425
The sum of 1/8.0 and the previous sum is 2.7178571428571425
The sum of 1/9.0 and the previous sum is 2.8289682539682537
The sum of 1/10.0 and the previous sum is 2.9289682539682538
The sum of 1/11.0 and the previous sum is 3.0198773448773446
The sum of 1/12.0 and the previous sum is 3.103210678210678
The sum of 1/13.0 and the previous sum is 3.180133755133755
The sum of 1/14.0 and the previous sum is 3.251562326562327
The sum of 1/15.0 and the previous sum is 3.3182289932289937
The sum of 1/16.0 and the previous sum is 3.3807289932289937
The sum of 1/17.0 and the previous sum is 3.439552522640758
The sum of 1/18.0 and the previous sum is 3.4951080781963135
The sum of 1/19.0 and the previous sum is 3.547739657143682
The sum of 1/20.0 and the previous sum is 3.597739657143682
The sum of 1/21.0 and the previous sum is 3.6453587047627294
The sum of 1/22.0 and the previous sum is 3.690813250217275
The sum of 1/23.0 and the previous sum is 3.73429151108684
The sum of 1/24.0 and the previous sum is 3.7759581777535067
The sum of 1/25.0 and the previous sum is 3.8159581777535068