Sum of square and cube digits of an integer are primes: Difference between revisions

m
(Added Arturo implementation)
Line 367:
<lang haskell>import Data.Bifunctor (first)
import Data.Numbers.Primes (isPrime)
 
---- SQUARE AND CUBE BOTH HAVE PRIME DECIMAL DIGIT SUMS --
 
p :: Int -> Bool
Line 372 ⟶ 374:
((&&) . primeDigitSum . (^ 2))
<*> (primeDigitSum . (^ 3))
 
 
--------------------------- TEST -------------------------
main :: IO ()
main = print $ filter p [2 .. 99]
 
 
------------------------- GENERIC ------------------------
Line 387:
where
go 0 = 0
go n = (uncurry (+) (. first go) $ quotRem n base)</lang>
{{Out}}
<pre>[16,17,25,28,34,37,47,52,64]</pre>
9,655

edits