eg0rmaffin

recursive factorial

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