




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































1 if N = 1 factorial( N ) = N * factorial( N-1 ) otherwise
public int factorial( int N ) { if ( N == 1 ) { return 1; } else { return N * factorial( N-1 ); } }
public int factorial( int N ) { if ( N == 1 ) { return 1; } else { return N * factorial( N-1 ); } } Test to stop or continue.
public int factorial( int N ) { if ( N == 1 ) { return 1; } else { return N * factorial( N-1 ); } } End case: recursion stops. Test to stop or continue. Recursive case: recursion continues.
public int factorial( int N ) { if ( N == 1 ) { return 1; } else { return N * factorial( N-1 ); } } factorial( 3 );
N public int factorial( int N ) { if ( N == 1 ) { return 1; } else { return N * factorial( N-1 ); } } factorial( 3 );
N public int factorial( int N ) { if ( N == 1 ) { return 1; } else { return N * factorial( N-1 ); } } factorial( 3 );
N public int factorial( int N ) { if ( N == 1 ) { return 1; } else { return N * factorial( N-1 ); } } factorial( 3 );