I've solved the Project Euler Problem #4, but I'd like some tips as to how to make this more efficient. I am a beginner to Ruby, so please be nice about the stupid stuffs (but still tell me about it).
Project Euler 4: Largest palindrome product
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. 1
class Euler4
def isPalindrome(n)
n == n.to_s.reverse.to_i
end
end
puts "Setting Variables"
x = 999
y = 999
highest = 1
found = false
while (x > 100 && !found)
y = 999
while (y > 100 && !found)
puts "Working with"
puts x
puts " and "
puts y
if Euler4.new.isPalindrome(x*y)
puts "Found Palindrome"
puts x
puts y
puts x*y
if highest < (x*y)
highest = x * y
end
end
y = y - 1
end
x = x - 1
end
puts "Highest Found"
puts highest