John Peterson wrote:
Add a type signature:
prime :: Integer -> Bool
It's defaulting to Int and you're getting overflows
Thanks. Hmm... it's still not working.
Btw, I mis-reported the problem. The offending number is 38466629, which
is /not/ prime but the sample program reports as prime.
38466629 = 31 * 1240859
The offending program is:
--//--
prime :: Integer -> Bool
prime n = not (factors 2 n)
factors :: Integer -> Integer -> Bool
factors m n | m == n = False
| m < n = divides m n || factors (m+1) n
divides :: Integer -> Integer -> Bool
divides a b = (mod a b == 0)
--//--
The math behind the program seems correct... :(
Cheers,
Daniel.
--
/\/`) http://oooauthors.org
/\/_/ http://opendocumentfellowship.org
/\/_/
\/_/ I am not over-weight, I am under-tall.
/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe