That of course is true Sensei - I had forgotten that it was I who had introduced the idea of the the leading zero.
I found that his Python code fails with f.e. num=30..
My .NET Framework version of it, is showing "30*1=44".
after using 64 bit integers I got:
30 * 143165578 = 4294967340
2^32 = 4294967296
4294967340 - 4294967296 = 44...
The most significant bit set, is truncated, because of overflow of 32 bit integer..
After using long long everywhere in code ends up in infinite loop (2^64 numbers to check).
Could you prove that for any integer n (not divisible by 10) there is a palindrome (in decimal representation) divisible by n?
Divisibility test for 11 is the answer you're searching for?
"Except for 11, all palindromic primes have an odd number of digits, because the divisibility test for 11 tells us that every palindromic number with an even number of digits is a multiple of 11."
Modified version of project. Instead of incrementing k by 1, it increments by 11.
Palindrome.zip 36.98KB 3 downloads