[Haskell] big integer in haskell
tting.wang at gmail.com
Fri Apr 15 19:03:22 EDT 2005
I am a new learner, and i am trying to write a function to calculate
factorial of a natural number:
(I use ghc 6.4, window xp)
fac :: Int -> Int
| n == 0 = 1
| n > 0 = fac (n-1) * n
| otherwise = 0
this works when n < 14 and result is 1278945280, when n > 14 the answer
is not right n = 15 result is 2004310016. I know it is maybe because of
overflow. So i calclate 2^32, 2^64, 2^128 the result correct and is much
bigger as 14!,Why? 2^n use some big integer or my implementation of n!
is not correct, I'm really confused.
Someone can help me?
More information about the Haskell