Difference between revisions of "Talk:99 questions/Solutions/31"

From HaskellWiki
Jump to: navigation, search
(New page: Does something like this deserves being put on the wiki ? <haskell> isPrime :: Int -> Bool isPrime n | n <= 1 = False isPrime n = isPrime' 2 n where isPrime' x n | x*x > n = True ...)
 
Line 1: Line 1:
Does something like this deserves being put on the wiki ?
+
Does something as simple but as dump as this should be on the wiki ?
 
<haskell>
 
<haskell>
 
isPrime :: Int -> Bool
 
isPrime :: Int -> Bool

Revision as of 09:29, 14 January 2012

Does something as simple but as dump as this should be on the wiki ?

isPrime :: Int -> Bool
isPrime n | n <= 1 = False
isPrime n = isPrime' 2 n
    where isPrime' x n | x*x > n   = True
                       | otherwise = (n `rem` x) /= 0 && isPrime' (x+1) n