Permalink
Browse files

everyone use the same algorithm

  • Loading branch information...
1 parent 6a13388 commit fd8c65751e337bcc350391497a34341f554b5572 @kscaldef kscaldef committed Sep 7, 2009
Showing with 4 additions and 4 deletions.
  1. +1 −1 haskell/004/01.hs
  2. +3 −3 perl5/004/01.pl
View
@@ -13,7 +13,7 @@ palindromes :: [Integer]
palindromes =
do
a <- [100..999]
- b <- [100..999]
+ b <- [a..999]
let prod = a * b
guard $ isPalindrome prod
return prod
View
@@ -4,15 +4,15 @@
# Problem 4
# 16 November 2001
-#
+#
# 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.
my $max = 0;
for my $a ( 100..999 ){
- for my $b ( 100..999 ){
+ for my $b ( $a..999 ){
my $product = $a * $b;
$max = $product if $product > $max

0 comments on commit fd8c657

Please sign in to comment.