FileDocCategorySizeDatePackage
Factorial.javaAPI DocExample784Mon Sep 22 13:30:30 BST 1997None

Factorial

public class Factorial extends Object
This class doesn't define a main() method, so it isn't a program by itself. It does define a useful method that we can use in other programs, though.

Fields Summary
Constructors Summary
Methods Summary
public static intfactorial(int x)
Compute and return x!, the factorial of x

    int fact = 1;
    for(int i = 2; i <= x; i++)    // loop
      fact *= i;                   // shorthand for: fact = fact * i;
    return fact;