Hi(adsbygoogle = window.adsbygoogle || []).push({});

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?

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Reducing Number of Multiplications in a Loop

**Physics Forums | Science Articles, Homework Help, Discussion**