Calculating Factorials in C
- Lucas
- August 18, 2011
Simple C program that calculates the factorial of any number: #include int main() { int fat, n; printf(“Enter a value for which you want to calculate your factorial: “); scanf(“%d”, &n); for(fat = 1; n > 1; n = n – 1) fat = fat * n; printf(“\nFactorial calculated: %d”, fat); return 0; } How