Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 13th, 2007, 8:51 PM   #1
truBlu
Newbie
 
Join Date: Sep 2007
Location: New Jersey
Posts: 13
Rep Power: 0 truBlu is on a distinguished road
Send a message via MSN to truBlu
A Math challenge

Mods: This doesn't belong in this forum. Originally I was going to ask about flash and disassembly but since that isn't the case here, it would be better off in the lounge. Please move it there.

Someone sent this link to me.

http://digicc.com/fido/fido.swf

It's a puzzle that has you randomly select a 3 or 4 digit number and then subtract from it a different 3 or 4 digit number created using the same digits. You then enter your answer into the flash program leaving out a digit that you have selected. The program then figures out which number you have selected. For example, if I pick 8530 and then rearrange that number to form 5803, the difference is 2727. By entering into the program any combination of 2, 7 and 7, it figures out that you selected the number 2.

What I'd like to know is how this is done. I've been sitting here for awhile now trying to see what kind of pattern emerges when you subtract two numbers with the same digits but I just don't see the pattern. This isn't a homework question so knowing the answer isn't the end of the world. It would just be nice to satisfy my own curiosity.
truBlu is offline   Reply With Quote
Old Nov 13th, 2007, 8:52 PM   #2
truBlu
Newbie
 
Join Date: Sep 2007
Location: New Jersey
Posts: 13
Rep Power: 0 truBlu is on a distinguished road
Send a message via MSN to truBlu
Re: A Math challenge

I'm figuring this out more as I go along. If you enter 0, you get 9. Enter 1 and you get 8 all the way up to 8 -> 1. Enter 9 and you get 9. The process at this point is trivial. The only thing I don't understand is why you need two numbers with the same digits. I don't know what property of numbers is being used.
truBlu is offline   Reply With Quote
Old Nov 13th, 2007, 9:02 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: A Math challenge

Google Magic Nines. You'll find this and lots of other similar "magical" goodies.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 13th, 2007, 9:07 PM   #4
truBlu
Newbie
 
Join Date: Sep 2007
Location: New Jersey
Posts: 13
Rep Power: 0 truBlu is on a distinguished road
Send a message via MSN to truBlu
Re: A Math challenge

That's interesting. I've seen other "magical" programs but I never realized it was all based on 9s.
truBlu is offline   Reply With Quote
Old Nov 13th, 2007, 10:39 PM   #5
MiKuS
Hobbyist Programmer
 
Join Date: Jun 2007
Posts: 136
Rep Power: 2 MiKuS is on a distinguished road
Re: A Math challenge

9 is an interesting number, it is the maximum number of cubes that are needed to sum to any positive integer.
MiKuS is offline   Reply With Quote
Old Nov 14th, 2007, 12:10 AM   #6
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 422
Rep Power: 4 Wizard1988 is on a distinguished road
Re: A Math challenge

There is some other interesting things about 9:
http://en.wikipedia.org/wiki/Casting_out_nines

Also since the topic is about Math tricks, do any of you guy know Vedic Math?

Here are some pages which explain what it is and how it works:
http://www.vedicmathsindia.org/tutorials.htm
http://en.wikipedia.org/wiki/Vedic_mathematics

There also are a bunch of vids on youtube, you just have to search for them.

I hope some of you will find this interesting and or useful.
__________________

Wizard1988 is offline   Reply With Quote
Old Nov 14th, 2007, 4:39 AM   #7
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
Re: A Math challenge

The real proof for this would be lengthy.

The digits always add up to a multiple of nine, so it is simple arithmetic to find the missing digit.

The number is a multiple of nine so the digits will add up to nine.

This is the part that is going to get cut short:
(As a side note, it won't work if you don't jumble the numbers at all)

Basically, if you have a number of four digits, it can be represented as a*10^3+b*10^2+c*10^1+d*10^0 -or- 1000a + 100b + 10c + d (a,b,c,d live in integers). If you jumble the digits, you will end up with:
a*10^e + b *10^f + c*10^g + e*10^h, where all variables are integers

when you subtract:
a*10^3 + b*10^2+c*10^1+d*10^0
-a*10^e + b *10^f + c*10^g + e*10^h
a*(10^3 - 10^e) + b * (10^2 - 10^f) + c * (10^1 - 10^g) + d * (10^0 - 10^h)

If you are familar with number theory, you may be familiar with modulo spaces. If not, I'm sure many people here can explain this. (im using '=' for modular equals, because i don't have the proper character set.)

Lemma 1: if a = 0(mod b), a is a multiple of b
Lemma 2: if a=b(mod c), a^k = b^k(mod c)

10 = 1(mod 9)

by lemma 2, since 10 = 1(mod 9), 10^k = 1(mod 9)

thus in (mod 9), 10^3 = 10^2 = 10^1 = 10^0 = 10^e = 10^f = 10^g = 10^h = 1

so 10^3 - 10^e in mod 9 is equivalent to 1 - 1, or 0;
10^2 - 10^f in mod 9 is equivalent to 1 - 1, or 0;
10^1 - 10^g in mod 9 is equivalent to 1 - 1, or 0; and
10^0 - 10^h in mod 9 is equivalent to 1 - 1, or 0.

From lemma 1, that means that all of these values are multiples of 9.

That means

so a*(10^3 - 10^e) will be a multiple of nine, as will b*(10^2 - 10^f) and so forth

When you add up these multiples of nine, they will equal a multiple of nine, due to the distributive property.


This is a lot sloppier than if written on paper, but hopefully it gets the point across.
I would assume this is a subset of what Dawei is referring to by "magic nines"

Last edited by Harakim; Nov 14th, 2007 at 4:41 AM. Reason: Salvage at least some clarity
Harakim is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Uman's WEEKEND CHALLENGE uman Coder's Corner Lounge 34 Aug 5th, 2008 10:25 PM
Computer Science Prereqs - Math bigguy Coder's Corner Lounge 22 Mar 15th, 2006 1:19 AM
Math Games Sane Coder's Corner Lounge 8 Dec 22nd, 2005 4:30 AM
Recommended math book to accompany course? Jessehk Coder's Corner Lounge 7 Nov 15th, 2005 7:05 PM
Weekend Challenge theduck Community Announcements and Feedback 43 Jun 3rd, 2005 5:58 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:33 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC