On Sun, Apr 25, 2010 at 6:34 AM, <[email protected]> wrote: > 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.
I won't go over your code, since more skilled people than me are already helping you out with it. However, once you've finished your own implementation, you may be interested in http://blog.natulte.net/posts/2010-04-23-delicious-primes.html . It may give you some interesting insights, imho as the post's author :-). - Dave > > > > > > _______________________________________________ > Haskell-Cafe mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
