27 lines
797 B
Text
27 lines
797 B
Text
A factorial is a number.
|
|
|
|
To run:
|
|
Start up.
|
|
Demonstrate input.
|
|
Write "Bye-bye!" to the console.
|
|
Wait for 1 second.
|
|
Shut down.
|
|
|
|
To demonstrate input:
|
|
Write "Enter a number: " to the console without advancing.
|
|
Read a string from the console.
|
|
If the string is empty, exit.
|
|
Convert the string to a number.
|
|
If the number is negative, repeat.
|
|
Compute a factorial of the number.
|
|
Write "Factorial of the number: " then the factorial then the return byte to the console.
|
|
Repeat.
|
|
|
|
To decide if a string is empty:
|
|
If the string's length is 0, say yes.
|
|
Say no.
|
|
|
|
To compute a factorial of a number:
|
|
If the number is 0, put 1 into the factorial; exit.
|
|
Compute another factorial of the number minus 1. \ recursion
|
|
Put the other factorial times the number into the factorial.
|