Factorial Calculator in Pascal
This program, written in Pascal, calculates the factorial of a given number using a recursive approach.
Overview
The FactorialCalculator prompts the user for an integer input. It then calculates the factorial of the number provided by the user using a recursive function. If a negative number is input, the user will be notified that they should provide a non-negative integer.
How to Run
Prerequisites
- A Pascal compiler, such as Free Pascal.
- Knowledge on how to compile and run Pascal programs.
Compilation and Execution
- Save the provided code into a file named
FactorialCalculator.pas
. - Compile the program using a Pascal compiler. For example, using Free Pascal:
fpc FactorialCalculator.pas
- After compilation, run the executable:
./FactorialCalculator
Usage
Upon execution, the program will prompt:
Enter a number to calculate its factorial:
Input a non-negative integer and press enter. The program will then display the factorial of the given number. If a negative number is input, you'll be prompted to enter a non-negative integer.