קוד:
NOTE: This program calculates the factorial of a number in two different ways
Define fact_it for n:
If n is less than 0:
Print "Invalid Argument" with newline
Return -1
Let result be 1
Repeat for i between 2 and n:
Set result to times i
Return result
Define fact_rec_wrap for n:
If n is less than 0:
Print "Invalid Argument" with newline
Return -1
Return fact_rec of n
Define fact_rec for n:
If n is 0 or n is 1:
Return 1
Return n times fact_rec of n minus 1
Define main:
Be n
Print "Choose an integer:" with newline
Read n
Let x be fact_it of n
Let y be fact_rec_wrap of n
Print x with newline
Print y with newline
If x is y:
Print "Kiiiiin" with newline
Return 0
Return -1