change $ to 0 to avoid stack overflow if n is large enough

master
nihonium 2 years ago
parent ae316f42fe
commit 6354df0b0c
No known key found for this signature in database
GPG Key ID: 0251623741027CFC

@ -5,7 +5,7 @@ factorial n = if n < 0 then
Left "n cannot be negative" Left "n cannot be negative"
else Right $ factorial' n 1 where else Right $ factorial' n 1 where
factorial' 0 res = res factorial' 0 res = res
factorial' n res = factorial' (n - 1) $ n * res factorial' n res = factorial' (n - 1) $! n * res
main :: IO() main :: IO()
main = do main = do