Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
15 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
def largest_palindrom_product_3_digits | ||
max_palindrom = 0 | ||
100.upto(999) do |factor1| | ||
100.upto(999) do |factor2| | ||
product = factor1 * factor2 | ||
if product.to_s == product.to_s.reverse then | ||
max_palindrom = product > max_palindrom ? product : max_palindrom | ||
end | ||
end | ||
end | ||
return max_palindrom | ||
end | ||
|
||
|
||
puts largest_palindrom_product_3_digits |