Help with programming exercise
807603Nov 20 2007 — edited Nov 20 2007This is my assignment:
Exercise 36 � Computation
Write a program that computes the following sum:
sum = 1.0/1 + 1.0/2 + 1.0/3 + 1.0/4 + 1.0/5 + .... + 1.0/N
N will be an integer limit that the user enters.
Enter N
4
Sum is: 2.08333333333
And this is what I have so far:
import learning.*;
class Computation
{
public static void main(String[] args)
{
int N;
double Sum;
System.out.println("Enter N");
N = LearningIO.readInt();
Sum = 1.0/N;
for ( N= 1; <=N ; Sum++)
{
System.out.println(Sum);
}
}
}
I don't know what to use for the termination process. Any help will be appreciated.