All we need to do is multiply by all numbers less than it. As the number reduces, there is a chance that the factorial will be greater than the number. Take for example 3! = (3*2*1) = 6. At step 1 (3*2) = 6 which is greater than the original number 3.

I hope I make sense.

]]>“A factorial is the result of a number multiplied by all positive integers less than that number”

However in the first example the code does not check to ensure the multiplier $factorial is less than $number.

]]>