FileDocCategorySizeDatePackage
Factorial2.javaAPI DocExample987Sat Jan 24 10:44:24 GMT 2004je3.basics

Factorial2

public class Factorial2 extends Object
This class shows a recursive method to compute factorials. This method calls itself repeatedly based on the formula: n! = n * (n-1)!

Fields Summary
Constructors Summary
Methods Summary
public static longfactorial(long x)

	if (x < 0) throw new IllegalArgumentException("x must be >= 0");
        if (x <= 1) return 1;              // Stop recursing here
        else return x * factorial(x-1);    // Recurse by calling ourselves