/*****************************************************************
** Factorial2 - same as Factorial, except using recursion
**
** (c) Scott MacKenzie, 2000                             
******************************************************************/
import java.io.*;

public class Factorial2
{
   public static void main(String[] args) throws IOException
   {
      BufferedReader stdin =
         new BufferedReader(new InputStreamReader(System.in), 1);

      System.out.print("Enter a non-negative integer: ");
      int n = Integer.parseInt(stdin.readLine());
      if (n < 0)
      {
         System.out.println("Oops!");
         return;
      }
      else   
      System.out.println(n + "! = " + factorial(n));
   }

   public static int factorial(int n)
   {
      if (n == 0)
         return 1;
      else
         return n * factorial(n - 1);
   }
}

