public class Factorial {
public static long factorial( int n ) {
if( n <= 1 )
return 1;
else
return n * factorial( n - 1 );
}
// Contoh Sederhana
public static void main( String [ ] args ) {
for( int i = 1; i <= 10; i++ )
System.out.println( factorial( i ) );
}
}
Selamat mencoba dan semoga bermanfaat...
0 comments:
Posting Komentar