Q:

How to stop summing a harmonic series when it reaches a specified target in Java?

I'm a complete beginner in Java who just recently got introduced to loops. I'm trying to do write a program that reads in a target and finds the first n such that 1 + 1/2 + 1/3 + ... + 1/n > target. The problem supplied a code with the initialization of n and sum missing as well as the condition of while and its statements missing.
I'm able to work out how to make the harmonic series loop, but I'm not sure what to set n with to stop the loop when it exceeds the target.We've not learned about arrays in class yet..  
import java.util.Scanner;

/**
 This program computes how many steps the sum 1 + 1/2 + 1/3 + ...
 needs to exceed a given target. 
 */
public class ReciprocalSum
{
    public static void main(String[] args)
    {  

        double sum = 0;
        int n = ????  ;

        Scanner in = new Scanner(System.in);
        System.out.print("Target: ");
        double target = in.nextDouble();
        int i = 0; 

//Notes 
        // 1 + 1/2 + 1/3 + 1/4 + ..... 1/n 
        //Make a loop that repeats itself starting with n = 1 --> 1/1 + 1/2 + 1/3 + 1/4 + 1/n 

        // 1.0/n + (1.0/ n - 1) + (1.0/n-2) +.... if n =4 --> 1/4 + 1/3 + 1/2 + 1/1 as long as n >0 

        while ( n > 0) 
        {  
            sum += 1.0/n ;
            n--; 
        }

        System.out.println("n: " + n);
        System.out.println("sum: " + sum);
    }
}

A:

n should be incremented in the loop (and therefore it should start at 0), and the loop should be exited when you reach the target:
int n = 0;

...

while (sum <= target) 
{  
    n++;
    sum += 1.0/n;
}

