Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int factorial( int n )
- {
- if ( n <= 1 )
- return 1;
- else
- return n * factorial( n-1 );
- }
- /*-------- main( ) starts here ------------------*/
- int main(void)
- {
- int N;
- int f;
- printf( "Enter n: " );
- scanf( " %i", &N );
- f = factorial( N );
- printf( "factorial of %i is %i\n", N, f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement