Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int factorial( int n )
  4. {
  5.     if ( n <= 1 )
  6.         return 1;
  7.     else
  8.         return  n * factorial( n-1 );
  9. }
  10.  
  11. /*-------- main( ) starts here ------------------*/
  12. int main(void)
  13. {
  14.     int N;
  15.     int f;
  16.  
  17.     printf( "Enter n: " );
  18.     scanf( " %i", &N );
  19.  
  20.     f = factorial( N );
  21.  
  22.     printf( "factorial of %i is %i\n", N, f);
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement