[ create a new paste ] login | about

Link: http://codepad.org/mTNnPb8l    [ raw code | output | fork ]

Haskell, pasted on Oct 21:
1
2
3
4
5
6
7
solution = filter (\(a,b) -> isPali b) $ zip paliDec (map toOct paliDec)
    where isPali n = show n == reverse (show n)
          paliDec = filter isPali [1..]
          toOct n | n < 8     = n
                  | otherwise = let (d, m) = divMod n 8 in 10 * toOct d + m

main = print $ take 20 solution


Output:
1
[(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(9,11),(121,171),(292,444),(333,515),(373,565),(414,636),(585,1111),(3663,7117),(8778,21112),(13131,31513),(13331,32023),(26462,63536),(26662,64046)]


Create a new paste based on this one


Comments: