Factorial in Groovy, Java

Example for versions Groovy 1.7, Sun Java 6, gcj 3.4.5

This example uses recursive factorial definition.

public class Factorial {
    static long factorial(int n)
    {
        return ( n==0 ? 1 : n*factorial(n-1) );
    }
    public static void main(String[] args)
    {
        for (int n=0; n<=16; n++)
            System.out.println(n+"! = "+factorial(n));
    }
}