Java examples for Object Oriented Design:Method
Recursive implementation of the factorial function
public class Main { public static int Factorial(int n) { if (n == 0)/* www. ja va 2 s. c o m*/ return 1; // Terminal stage else return n * Factorial(n - 1); // Apply recurrence equation } public static void main(String[] arg) { System.out.println("10!=" + Factorial(10)); } }