Init: refactored factorial function using `foldl`