Smallest power of 6 whose decimal expansion contains n: Difference between revisions
Content added Content deleted
(Realize in F#) |
Not a robot (talk | contribs) (Add Haskell) |
||
Line 154: | Line 154: | ||
21 216 |
21 216 |
||
</pre> |
</pre> |
||
=={{header|Haskell}}== |
|||
<lang haskell>import Control.Monad |
|||
import Data.List |
|||
import Text.Printf |
|||
sixes :: [Integer] |
|||
sixes = iterate (*6) 1 |
|||
smallest :: Integer -> Integer |
|||
smallest n = head $ filter (\r -> show n `isInfixOf` show r) sixes |
|||
main :: IO () |
|||
main = putStr $ concatMap (printf "%2d: %d\n" `ap` smallest) [0..21]</lang> |
|||
{{out}} |
|||
<pre> 0: 10077696 |
|||
1: 1 |
|||
2: 216 |
|||
3: 36 |
|||
4: 46656 |
|||
5: 46656 |
|||
6: 6 |
|||
7: 7776 |
|||
8: 2176782336 |
|||
9: 1296 |
|||
10: 10077696 |
|||
11: 2821109907456 |
|||
12: 1296 |
|||
13: 13060694016 |
|||
14: 6140942214464815497216 |
|||
15: 101559956668416 |
|||
16: 216 |
|||
17: 60466176 |
|||
18: 470184984576 |
|||
19: 21936950640377856 |
|||
20: 170581728179578208256 |
|||
21: 216</pre> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |