/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		System.out.println("Rec:   " + RecursiveFunction(1000));
		System.out.println("Flat0: " + NonRecursiveFunction0(1000));
		System.out.println("Flat1: " + NonRecursiveFunction1(1000));
	}
	
	static float RecursiveFunction(int num){
	    //The num parameter represents the denominator that will be used
	    //The recursive function is continually called at lower increments of num
	
	    //If num is one, return 1 and do not call RecursiveFunction again
	    if (num == 1) {
	        return 1;
	    }
	    //Otherwise, return 1/num (in floating point decimal) and call RecursiveFunction with a parameter of num - 1
	    else {
	        return 1/(float)num + RecursiveFunction(num - 1);
	    }
	}
	
	//A Non-recursive version of RecursiveFunction that will be used to test RecursiveFunction
	static float NonRecursiveFunction0(int num) {
	    //The total variable adds up the fractions
	    float total = 0;
	    //While num is greater than zero, add 1/num to total and then subtract 1 from num
	    while (num > 0) {
	        total += 1/(float)num;
	        num -= 1;
	    }
	    return total;
	}
	
	//A Non-recursive version of RecursiveFunction that will be used to test RecursiveFunction
	static float NonRecursiveFunction1(int num) {
	    //The total variable adds up the fractions
	    float total = 0;
	    //While num is greater than zero, add 1/num to total and then subtract 1 from num
	    for (int i = 1; i <= num; ++i)
	    {
	    	total += 1.0f / i;
	    }
	    return total;
	}
}