Factorial In Java

This item was filled under [ Example, Java, Programming, Tutorial ]

Simple code “Factorial in Java”

public class Factorial {
public static long factorial( int n ) {
if( n <= 1 )
return 1;
else
return n * factorial( n - 1 );
}

public static void main( String [ ] args ) {
for( int i = 1; i <= 10; i++ )
System.out.println( factorial( i ) );
}
}

:)

Tagged with: [ , ]
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Comments on “Factorial In Java”

  • 3 February, 2010, 13:21

    bagus lebih singkat dari pada hafal yang panjang…….. thax you ya ^_^

  • admin
    10 March, 2010, 12:18

    ok…
    Terima kasih…

Leave a Comment