Skip to content

Instantly share code, notes, and snippets.

@reuk
Created August 18, 2013 09:45
Show Gist options
  • Save reuk/6260802 to your computer and use it in GitHub Desktop.
Save reuk/6260802 to your computer and use it in GitHub Desktop.
My first Project Euler solution using Haskell. This one (number 55) finds how many Lychrel numbers are smaller than 10000.
solve = isLychrel 0
where isLychrel i x | d == reverse d = False
| i > 50 = True
| otherwise = isLychrel (i + 1) c
where b = reverse $ show x
c = (x + (read b :: Integer))
d = show c
main = print $ length $ filter (== True) $ map solve [1..9999]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment