[Haskell-cafe] I need help getting started

mitchell at kaplan2.com mitchell at kaplan2.com
Sun Apr 25 00:34:32 EDT 2010



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


          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.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100425/035c03dc/attachment.html

More information about the Haskell-Cafe mailing list