Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int fatorial (int n)
- {
- if (n == 0)
- return 1;
- else if (n<0){
- printf("\nErro: fatorial de numero negativo!\n");
- getch();
- exit(0);
- }
- return n*fatorial(n-1);
- }
- int main(void)
- {
- int n, fat=1;
- printf("Digite um numero inteiro:");
- scanf("%d", &n);
- fat=fatorial(n);
- printf("\n\nO fatorial de %d eh: %d", n,
- fat);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement