13.07.2015 Views

6.042J Chapter 4: Number theory - MIT OpenCourseWare

6.042J Chapter 4: Number theory - MIT OpenCourseWare

6.042J Chapter 4: Number theory - MIT OpenCourseWare

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

“mcs-ftl” — 2010/9/8 — 0:40 — page 84 — #90<strong>Chapter</strong> 4<strong>Number</strong> TheoryThe number q is called the quotient and the number r is called the remainder ofn divided by d. We use the notation qcnt.n; d/ for the quotient and rem.n; d/ forthe remainder.For example, qcnt.2716; 10/ D 271 and rem.2716; 10/ D 6, since 2716 D271 10 C 6. Similarly, rem. 11; 7/ D 3, since 11 D . 2/ 7 C 3. Thereis a remainder operator built into many programming languages. For example,the expression “32 % 5” evaluates to 2 in Java, C, and C++. However, all theselanguages treat negative numbers strangely.4.1.3 Die HardSimon: On the fountain, there should be 2 jugs, do you see them? A 5-gallon anda 3-gallon. Fill one of the jugs with exactly 4 gallons of water and place it onthe scale and the timer will stop. You must be precise; one ounce more or lesswill result in detonation. If you’re still alive in 5 minutes, we’ll speak.Bruce: Wait, wait a second. I don’t get it. Do you get it?Samuel: No.Bruce: Get the jugs. Obviously, we can’t fill the 3-gallon jug with 4 gallons ofwater.Samuel: Obviously.Bruce: All right. I know, here we go. We fill the 3-gallon jug exactly to the top,right?Samuel: Uh-huh.Bruce: Okay, now we pour this 3 gallons into the 5-gallon jug, giving us exactly3 gallons in the 5-gallon jug, right?Samuel: Right, then what?Bruce: All right. We take the 3-gallon jug and fill it a third of the way. . .Samuel: No! He said, “Be precise.” Exactly 4 gallons.Bruce: Sh—. Every cop within 50 miles is running his a— off and I’m out hereplaying kids’ games in the park.Samuel: Hey, you want to focus on the problem at hand?The preceding script is from the movie Die Hard 3: With a Vengeance. In themovie, Samuel L. Jackson and Bruce Willis have to disarm a bomb planted by thediabolical Simon Gruber. Fortunately, they find a solution in the nick of time. (Nodoubt reading the script helped.) On the surface, Die Hard 3 is just a B-gradeaction movie; however, we think the inner message of the film is that everyoneshould learn at least a little number <strong>theory</strong>.Unfortunately, Hollywood never lets go of a gimmick. Although there were nowater jug tests in Die Hard 4: Live Free or Die Hard, rumor has it that the jugs will4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!