Extra primes: Difference between revisions

no edit summary
(Added Quackery.)
No edit summary
Line 1,235:
35: 7723
36: 7727
</pre>
 
=={{header|Haskell}}==
<syntaxhighlight lang="haskell">
import Data.Char ( digitToInt )
 
isPrime :: Int -> Bool
isPrime n
|n < 2 = False
|otherwise = null $ filter (\i -> mod n i == 0 ) [2 .. root]
where
root :: Int
root = floor $ sqrt $ fromIntegral n
 
condition :: Int -> Bool
condition n = isPrime n && all isPrime digits && isPrime ( sum digits )
where
digits :: [Int]
digits = map digitToInt ( show n )
 
solution :: [Int]
solution = filter condition [1..9999]</syntaxhighlight>
 
{{out}}
<pre>
[2,3,5,7,23,223,227,337,353,373,557,577,733,757,773,2333,2357,2377,2557,2753,2777,3253,3257,3323,3527,3727,5233,5237,5273,5323,5527,7237,7253,7523,7723,7727]
</pre>
 
258

edits