
20 Jan
2013
20 Jan
'13
6:27 p.m.
On Mon, 21 Jan 2013, miphis@meta.ua wrote:
The program looks like this:
--*********************** factorial :: Int->Int factorial n = product [1..n]
main = do print $ factorial 50 --***********************
And that yields "0" (no errors). Is it a bug or feature? :)
This question is certainly better posted to haskell-cafe. The answer is: Int has limited bitsize (32 ord 64 bit depending on your machine), thus it computes factorial modulo 2^32 or 2^64. You can get the correct result by replacing Int by Integer.