Skip to content

Instantly share code, notes, and snippets.

@takuma7
Created October 23, 2010 02:08
Show Gist options
  • Save takuma7/641678 to your computer and use it in GitHub Desktop.
Save takuma7/641678 to your computer and use it in GitHub Desktop.
Project Euler - Problem 4
import System.IO
main = do
putStrLn $ biggest "0" [ show (a*b) | a <- [100..999], b <- [100..999], isPalindromicNum (show (a*b))]
isPalindromicNum [] = True
isPalindromicNum (_:[]) = True
isPalindromicNum (x:xs) | x == last xs = isPalindromicNum (init xs)
| otherwise = False
biggest m [] = m
biggest m (x:xs) | x' > m' = biggest x xs
| otherwise = biggest m xs
where x' = (read x)::Integer
m' = (read m)::Integer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment