Advertisement
H_I

Untitled

H_I
Dec 27th, 2024
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int factorial(int n);
  4.  
  5. int main ()
  6. {
  7.     int result;
  8.    
  9.     result = factorial(3);
  10.     printf("result is %d", result);
  11.     return 0;
  12.    
  13.    
  14. }
  15.  
  16. int factorial(int n)
  17. {
  18.     if (n<=1)
  19.     {
  20.         return 1;
  21.     }
  22.  
  23.     return factorial(n-1)*n;
  24.    
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement