2
When creating a number factor algorithm with while I see that by input of the number 21 onwards, the result is wrong -negative.
#include <stdio.h>
long int i=1, ii=1, num, fat=1, somatorio;
int main (){
while(i <= 5){
printf("Insira um número: ");
scanf("%ld", &num);
ii = 1;
fat = 1;
while(ii <= num){
fat = fat * ii;
ii++;
}
printf("Fatorial: %ld\n",fat);
somatorio = fat + somatorio;
i++;
}
printf("\nSomatório dos fatoriais: %ld\n\n", somatorio);
}
The program should read 5 numbers and at the end present the sum of factorial.