← all problems

factorial 🌶️

Write a method factorial that takes an int n (0 to 12) and returns n!: the product of every whole number from 1 up to n. factorial(5) is 1 2 3 4 5, which is 120, and factorial(0) is 1 (an empty product). Use a for loop.