Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- #include<locale.h>
- int main()
- {
- setlocale(LC_ALL, "Portuguese");
- int fatorial,
- resposta = 1;
- printf("Cálculo de fatorial\n");
- printf("====================\n");
- printf("Digite o valor:\n");
- scanf("%i", &fatorial);
- if(fatorial == 0){
- printf("Sua resposta e : %i\n",resposta);
- } else if(fatorial < 0){
- printf("Nao existe fatorial de numero negativo\n");
- return 0;
- }
- while(fatorial > 1){
- resposta*=fatorial;
- --fatorial;
- }
- printf("Sua resposta e : %i\n",resposta);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement