Super-d numbers: Difference between revisions

Content added Content deleted
No edit summary
Line 239: Line 239:
import Data.Char (intToDigit)
import Data.Char (intToDigit)


superd :: (Show a, Integral a) => a -> a -> Bool
isSuperd :: (Show a, Integral a) => a -> a -> Bool
superd p n = replicate (fromIntegral p) (intToDigit $ fromIntegral p) `isInfixOf` show (p * n ^ p)
isSuperd p n = replicate (fromIntegral p) (intToDigit $ fromIntegral p) `isInfixOf` show (p * n ^ p)


findSuperd :: (Show a, Integral a) => a -> [a]
findSuperd :: (Show a, Integral a) => a -> [a]
Line 246: Line 246:
where go [] = []
where go [] = []
go (n:ns)
go (n:ns)
| superd p n = n : go ns
| isSuperd p n = n : go ns
| otherwise = go ns
| otherwise = go ns


main :: IO ()
main :: IO ()
Line 259: Line 259:
First 10 super-6 : [27257,272570,302693,323576,364509,502785,513675,537771,676657,678146]
First 10 super-6 : [27257,272570,302693,323576,364509,502785,513675,537771,676657,678146]
</pre>
</pre>

=={{header|J}}==
=={{header|J}}==
<pre>
<pre>