🪆 Recursion · Mission 2 of 5
❗ Factorial
5! (5 factorial) is 5 × 4 × 3 × 2 × 1 = 120. Put another way: 5! is 5 × 4!. A function can use itself for the smaller one.
Your mission
- Make a Function called fact, given n.
- If n <= 1, Return 1. Otherwise Call fact(n - 1) into smaller, and Return n * smaller.
- Main program: Ask for a number into n, Call fact(n) into answer, and Tell n + "! = " + answer.
Getting the mission ready…