//--------------------------------------------------------------- // // r1.cpp // // An example of a recursive function: factorial // // Written by: Simon Parsons // Date: 28th November 2007 // #include using namespace std; int factorial ( int N ) { if ( N == 1 ) return( 1 ); else return( N * factorial( N-1 )); } // end of factorial() int main() { cout << "5! = " << factorial( 5 ) << endl; }