Re: [Haskell-cafe] Writing a function isPrime using recursion.

2008-10-15 Thread Nathan Bloomfield
At the risk of doing someone's homework... A naive solution is to do trial division by all integers from 2 up to sqrt n. {- isPrime :: Integer -> BoolisPrime n | n < 2 = False | otherwise = f 2 n where f k n = if k > isqrt then True else undefined -- exercise for the reader -}

Re: [Haskell-cafe] Writing a function isPrime using recursion.

2008-10-15 Thread Bulat Ziganshin
Hello Kalashnikov, Thursday, October 16, 2008, 2:41:05 AM, you wrote: > I'm supposed to write a function isPrime that checks whether or not a given > integer is a prime number or not. The function has to use recursion. The > only advice I was given, was to use a helper function. seems that russi

[Haskell-cafe] Writing a function isPrime using recursion.

2008-10-15 Thread Kalashnikov
I'm supposed to write a function isPrime that checks whether or not a given integer is a prime number or not. The function has to use recursion. The only advice I was given, was to use a helper function. I still have no clue how to do it :confused: I'm new to Haskell by the way..please help.. --