=begin 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. =end n = 3 start = 10**n - 1 start.downto 10**(n-1) do |i| j = (i.to_s+i.to_s.reverse).to_i Math.sqrt(j).floor.downto 10**(n-1) do |k| qt = j / k.to_f if qt == qt.truncate && qt.truncate.to_s.length == n print(j.to_s+' = '+qt.to_s+' * '+k.to_s+"\n") exit end end end