Created
May 26, 2011 08:16
-
-
Save johana-star/992758 to your computer and use it in GitHub Desktop.
Euler Project Problem #004
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Solution to Project Euler's fourth problem | |
# http://projecteuler.net/index.php?section=problems&id=4 | |
# Find the largest palindromic number which is the product of two three-digit numbers. | |
def generate_and_test | |
numbers = [] | |
999.downto(100) do |x| | |
999.downto(100) do |y| | |
number = x * y | |
if number.to_s == number.to_s.reverse then | |
numbers.push number | |
end | |
end | |
end | |
puts numbers.sort.last | |
p numbers.sort | |
end | |
generate_and_test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment