With the following function:
factorial :: Int -> Int
factorial n = product [1..n]
The correct value is returned with parameters less than 21. For example:
factorial 20
returns 2432902008176640000, but factorial 21
returns -4249290049419214848 which isn't correct even if the value wasn't negative.
I know that with these size numbers Integer
should have been utilized, but where specifically is the error occurring here and why?