Talk:99 questions/Solutions/31

From HaskellWiki
Revision as of 09:27, 14 January 2012 by Ibizaman (talk | contribs) (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 ...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Does something like this deserves being put 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