Sum of square and cube digits of an integer are primes: Difference between revisions
Sum of square and cube digits of an integer are primes (view source)
Revision as of 15:23, 15 April 2022
, 2 years ago→{{header|Haskell}}: Tidied.
Drkameleon (talk | contribs) (Added Arturo implementation) |
m (→{{header|Haskell}}: Tidied.) |
||
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 (+)
{{Out}}
<pre>[16,17,25,28,34,37,47,52,64]</pre>
|