Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's the rule?

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
0
0
US
Here's an interesting one:

Read your mind

Now I usually can figure out how these "read your mind" programs work, but this one's got me stuck.

I know that when numbers are transposed it's a multiple of nine, and I figure that must be part of it, but I can't seem to put it all together.

Anybody interested in putting together the code to solve this? Or know the math rules that are being utilized?

les
 
Looks like casting out 9's to me.

Total the digits in the remainder (except the circled one), then do a mod9. Take this and subtract it from 9, and that is the circled digit.

Circled digit = 9 - mod9(sum of digits in remaider less circled digit).


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
Start with a 3 digit number:

100a + 10b + c

The transposition and subtract operation will give you

(0 OR 90a OR 99a) + (-90b OR 0 OR 9b) + (-99c OR -9c OR 0)

Whichever value is in each of those brackets it's gonna be a multiple of 9, it's also gonna be positive as we always take the smaller from the bigger.

In all multiples of 9, the digits will add up to a multiple of 9. So if we take a digit out and add up the rest, the missing one must be whatever's needed to take us up to the next multiple of 9.

The only problem is, if we take a digit out and the remaining ones still add up to a multiple of 9, the missing digit could be either 0 or 9. That's why he won't let you circle a 0.



-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top