News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Numeric palindromes

Started by sinsi, October 29, 2007, 11:17:30 AM

Previous topic - Next topic

sinsi

Something on the back page of our Sunday paper.
QuoteAll palindromes with an even number of digits are divisible by 11
I assume he means "evenly divisible".

Just a bit of trivia that I found interesting...now to write the program to test it.
Light travels faster than sound, that's why some people seem bright until you hear them.

Mark Jones

Here is an easy way to test if a number (three digits or larger) is divisible by 11:

176 - this number is... 1+6 = 7 and 7 = 7
3542 - this number is... 3+4 = 7 and 5+2 = 7
92081 - this number is... 9+0+1 = 10 and 2+8 = 10
123456 - this number is not... 1+3+5 = 9   !==  2+4+6 = 12, however
123453 - this number is... 1+3+5 =9, and 2+4+3 = 9
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

raymond

Stated differently, it means that all palindromes with an even number of digits are multiples of 11. And you don't have to write a program to test that. As Mark Jones indicated, if the sum of every second digit is the same as the sum of the remaining digits (or if their difference is a multiple of 11), the number is a multiple of 11.

Consider the following palindrome where you can replace any of the letters by whatever digit you want:

ABCDEFFEDCBA

the sum of every 2nd digit is: A+C+E+F+D+B = A+B+C+D+E+F
and the sum of the remaining digits is: B+D+F+E+C+A = A+B+C+D+E+F

Therefore .......

When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com