You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
355 B
Plaintext

# Recursion
# Method for when the solution to a problem depends on solutions to smaller
# instance of the same problem; a self-calling function.
# Recursive programs - Pseudocode
function factorial:
input: integer n such that n >= 0
output: n * (n-1) * (n-2) * ... * 1 = n!
1. if n is 0, return 1
2. else, return ( n * factorial(n-1) )