import cs1.Keyboard;

/*
 * Created on Jul 30, 2005
 * 
 * CPS 006 - Summer 05
 * Sam Slee
 * RecFact.java
 * 
 * Takes a positive integer 'n' from the user
 * recursively computes n!, then prints that value.
 */

public class RecFact {

	//--------------------------------------------------------------------
	// Takes in an positive integer value n from the user
	// - and prints out the value of n!
	public static void main(String[] args) {
		long num, numFactorial;
		
		/*  
		  prompting the user for input  
		*/
		System.out.print("Enter the positive number you want the factorial of, here->");
		num = Keyboard.readInt();
		
		numFactorial = factorial(num);
		
		// printing out the answer
		System.out.println("The answer is: "+numFactorial);
	}
	
	
	//--------------------------------------------------------------------
	// Input:  positive integer "n"
	// Output: value of n!
	public static long factorial(long n){
		long m;
		
		if(1 == n)
			return 1;
		else{
			m = factorial(n-1);
			return n * m;
		}
	}
}
