Skip to content

Instantly share code, notes, and snippets.

@2GMon
Created August 27, 2012 03:01
Show Gist options
  • Save 2GMon/3485208 to your computer and use it in GitHub Desktop.
Save 2GMon/3485208 to your computer and use it in GitHub Desktop.
Project Euler : Problem 36
-- Project Euler : Problem 36
binary :: Integer -> String
binary 0 = "0"
binary 1 = "1"
binary n = (binary $ fst div) ++ (show $ snd div)
where div = n `divMod` 2
main = print $ sum [a | a <- [1..999999],
(show a) == (reverse $ show a),
(binary a) == (reverse $ binary a)
]
-- 872187
-- ./dailycoding36 0.38s user 0.00s system 99% cpu 0.383 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment