Created
August 20, 2011 23:14
Revisions
-
evansneath revised this gist
Aug 20, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def palindromes(min, max): while a < max: while b < max: product = a * b # determine if the product is reversible if str(product)[::-1] == str(product): if product > highest: highest = product -
evansneath revised this gist
Aug 20, 2011 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,9 +11,11 @@ def palindromes(min, max): while a < max: while b < max: product = a * b # determine if the product is reverible if str(product)[::-1] == str(product): if product > highest: highest = product b = b + 1 a, b = a + 1, min return highest -
evansneath created this gist
Aug 20, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ def palindromes(min, max): """Finds the largest palindrome of the product of two numbers between an desired range. Arguments: min: Minimum value limit. max: Maximum value limit. Returns: Largest palindrome of the product of two numbers between the established range. """ a, b, product, highest = min, min, 0, 0 while a < max: while b < max: product = a * b if str(product)[::-1] == str(product): # if reversible... if product > highest: highest = product b = b + 1 a, b = a + 1, min return highest