Find a six digit number which, when multiplied by an integer
between 2 and 9 inclusive, gives the original six digit number
with it's digits reversed.
Source: Math and Logic Puzzles for PC Enthusiasts,
J. J. Clessa. Problem # 34.
This is an ideal beginner's program illustrating trial and error solution techniques. Since there are about a million 6 digit integers, (900,000 if we start at 100,000), we should be able try them all in pretty short order. With each number to be tested, we'll split it into it's component digits, build up a number with the digits reversed, then see if the second is a single digit multiple of the first. The code provides the best description of the algorithm.
I've added QueryPerformanceCounter procedure calls to get run time - about a second to check all 900,000 on my medium speed Celeron CPU. And we really don't have to check any higher than 500,000 (why?).
A single procedure (SolveBtnClick) with about 30 lines of user written code keep this one in the beginner's category.
Five or seven digit numbers? Is there a pattern here?
Modified: November 07, 2008