factorials_pascal
Factorials in Pascal!
- Active · last change 7-17-2026
- ★ 1 on GitHub
README
Factorial
A small Pascal program that calculates and prints the factorial of every integer from 0 to 16.
What it does
The program defines a recursive factorial function that computes n! using the standard recursive definition:
factorial(0) = 1factorial(n) = n * factorial(n-1)forn > 0
The main block loops from 0 to 16, printing each value alongside its factorial.
Why 16
factorial returns a longint. Factorials grow very quickly, and 17! already exceeds the range a longint can hold, so the loop stops at 16 to avoid overflow.
Running it
Compile and run with any standard Pascal compiler, for example Free Pascal:
fpc factorial.pas
./factorialExample output
0! = 1
1! = 1
2! = 2
3! = 6
...
16! = 20922789888000Author
blockersiontko
License
MIT

