RosettaCodeData/Task/Super-d-numbers/Haskell/super-d-numbers.hs
2023-07-01 13:44:08 -04:00

17 lines
447 B
Haskell

import Data.List (isInfixOf)
import Data.Char (intToDigit)
isSuperd :: (Show a, Integral a) => a -> a -> Bool
isSuperd p n =
(replicate <*> intToDigit) (fromIntegral p) `isInfixOf` show (p * n ^ p)
findSuperd :: (Show a, Integral a) => a -> [a]
findSuperd p = filter (isSuperd p) [1 ..]
main :: IO ()
main =
mapM_
(putStrLn .
("First 10 super-" ++) .
((++) . show <*> ((" : " ++) . show . take 10 . findSuperd)))
[2 .. 6]