Overview

 

Question

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is \(9009 = 91 \times 99\).

Find the largest palindrome made from the product of two 3-digit numbers.

click for answer

906609

Solutions

 

Ruby

 palindrome.rb https://raw.github.com/addamh/euler/master/004/palindrome.rb download
#!/usr/bin/env ruby

store = Array.new
(100..999).each do |x|
   (100..999).each do |y|
      product = x*y
      if product.to_s == product.to_s.reverse
         store << product
      end
   end
end
store = store.sort
puts store.last
$ time ruby palindrome.rb
real	0m1.137s
user	0m1.131s
sys	0m0.004s