- #1
rwinston
- 36
- 0
Hi
Following on from my palindromic number question, if I am calculating a set of palindromic numbers generated as the product of two three-digit numbers, I could generate the entire product set and then test each number for the palindrome property.
the naive approach would be a loop like
for (i in 999:100)
for (j in 999:100)
p = i * j
However, we do many redundant multiplications this way, so the obvious approach is to do
for (i in 999:100)
for (j in i:100)
p= i * j
However, I still a lot of palindromic numbers that are duplicated. for instance, the palindrome 444444 is generated by:
962 * 462 = 444444
924 * 481 = 444444
858 * 518 = 444444
814 * 546 = 444444
777 * 572 = 444444
Is there any way to avoid or predict these multiplications of two 3-digit numbers that will produce duplicate palindromes?
Following on from my palindromic number question, if I am calculating a set of palindromic numbers generated as the product of two three-digit numbers, I could generate the entire product set and then test each number for the palindrome property.
the naive approach would be a loop like
for (i in 999:100)
for (j in 999:100)
p = i * j
However, we do many redundant multiplications this way, so the obvious approach is to do
for (i in 999:100)
for (j in i:100)
p= i * j
However, I still a lot of palindromic numbers that are duplicated. for instance, the palindrome 444444 is generated by:
962 * 462 = 444444
924 * 481 = 444444
858 * 518 = 444444
814 * 546 = 444444
777 * 572 = 444444
Is there any way to avoid or predict these multiplications of two 3-digit numbers that will produce duplicate palindromes?
Last edited: