[Haskell-cafe] Prime numbers
daniel.carrera at zmsl.com
Tue Dec 20 11:53:31 EST 2005
Henning Thielemann wrote:
>>factors :: Integer -> Integer -> Bool
>>factors m n | m == n = False
>> | m < n = divides m n || factors (m+1) n
> Btw. I find the recursion harder to understand than the explicit
> factors n = any (divides n) [2..(n-1)]
For what it's worth, I also found this function un-intuitive. What I'd
expect a function called "factors" to do is exactly what yours does, and
not what the one in the example does.
\/_/ I am not over-weight, I am under-tall.
More information about the Haskell-Cafe