
25 Apr
2010
25 Apr
'10
12:34 a.m.
Hi, I'm just starting to learn, or trying to learn Haskell. I want to write a function to tell me if a number's prime. This is what I've got: f x n y = if n>=y then True else if gcd x n == 1 then f x (n+1) y else False primeQ x = f x 2 y where y = floor(sqrt(x)) The compiler is very unhappy. Apparently there's some ambiguity in this, and I'm kind of running around in circles. I'd appreciate any help that will get me started.