Sunday, August 14, 2011

Problem 4

prob4.hs Problem 4
Filename: prob4.hs
--A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91  99.
--
--Find the largest palindrome made from the product of two 3-digit numbers.
module Prob4
    where
      isPalindrome x = x == (read (reverse (show x))::Integer)
  
      answer = maximum(filter isPalindrome ([x*y | x <- [100..999], y <- [100..999]]))

    

syntax highlighted by Code2HTML, v. 0.9.1

No comments:

Post a Comment