palindrome :: (Integral a, Show a) => a -> Bool
palindrome x = (show x) == reverse (show x)

prime :: Int -> Bool
prime 1 = False
prime x = prime' x (x-1)
  where
    prime' _ 1 = True
    prime' a b = case a `mod` b of
        0 -> False
        x -> prime' a (b-1)

main = do
    print $ head $ filter prime $ filter palindrome [1000, 999..1]
