Factorial Program
Description
This program inputs a positive integer n and then calculates n!.n! = n * (n - 1)* (n - 2) * ... * 1
Associated Concepts:
while loop
long integer data type
long integer data type
Algorithm:
Declare variables and initialize the long integer
result (64 bits) to 1
Input an integer n from the keyboard
Set the control variable i to n
Use a while to check the control variable i
(as long as i is greater than or equal to 1)
Multiply result by i and update result to the new value
Decrement i by 1
Print the result after the loop is ended
Input an integer n from the keyboard
Set the control variable i to n
Use a while to check the control variable i
(as long as i is greater than or equal to 1)
Multiply result by i and update result to the new value
Decrement i by 1
Print the result after the loop is ended
Source Code

Sample Run
