Advertisement
Viniciusd

Untitled

Jun 1st, 2013
54
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. #include <stdlib.h>
  3.  
  4. int fatorial(int n)
  5. {
  6.     if(n == 0 || n == 1)
  7.     {
  8.         return 1;
  9.     } else
  10.     {
  11.         return n*fatorial(n-1);
  12.     }
  13. }
  14.  
  15. int main(int argc, char **argv)
  16. {
  17.     int n;
  18.     printf("Digite o número\n");
  19.     printf("O fatorial de %d é %d", n, fatorial(n));
  20.     return(0);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement