本书暂未推出简体中文版。现有版本:English, Français。
Interviews I: Maths, Probability and Speed · 职业发展
6Number Riddles
Puzzles about whole numbers: the hands of a clock, factorials, remainders, last digits, divisibility, and which amounts can be made from given coins. They reward working modulo a small number and finding a structure rather than a lot of cases. The early questions are warm-ups, and the last ones need real persistence.
Question 6.1 ★ QT, Trader, Analyst • any • junior
What is the angle between the hour and minute hands of a clock at 4:36? Both hands move continuously.
Answer
Answer to Question 6.1.
The angle is 78 degrees.
Work from 12 o’clock. The minute hand moves 6 degrees a minute, so at 36 minutes it is at 216 degrees. The hour hand moves half a degree a minute, so at 4:36 it is at degrees. The difference is 78 degrees.
Classic wrong answer. Using degrees for the hour hand, as if it stayed on the 4 for the whole hour. That gives 96.
Follow-up. When do the hands first coincide after 4:00? The minute hand gains degrees a minute, and it starts 120 degrees behind, so after minutes, which is about 4:21:49.
Follow-up. How often do they coincide? Eleven times in 12 hours, so every of an hour, which is every 65 minutes and about 27 seconds.
Question 6.2 ★ QR, QT, Trader, QD, Dev • any • junior
How many zeros does end in, when written out in ordinary decimal digits?
Answer
Answer to Question 6.2.
ends in 62 zeros.
A trailing zero needs a factor of 10, which is a 2 and a 5. There are many more 2s than 5s among the factors, so the count of 5s decides it. Using Legendre’s formula, multiples of 5 give , multiples of 25 give a further 10, and multiples of 125 give a further 2. The total is 62.
Classic wrong answer. Stopping at . A multiple of 25 holds two 5s and a multiple of 125 holds three.
Follow-up. Which factorial ends in exactly 5 zeros? None. has 4 zeros, and has 6, because the factor 25 brings two 5s at once.
Follow-up. And the last non-zero digit? That is harder, since you must track the unmatched 2s. For , the number is 3628800, so the last non-zero digit is 8.
Question 6.3 ★ QR, QT, Trader • any • junior
Without a calculator, what is the last digit of when it is written out in decimal?
Answer
Answer to Question 6.3.
The last digit is 9.
Only last digits matter for the last digit of a product. Powers of 7 end in 7, 9, 3, 1 and then repeat, with period 4. Since , the power has the same last digit as .
Classic wrong answer. Using 2026 as if the last digit cycled with period 10. Look at the first few powers, and read the period off directly.
Follow-up. What is the last digit of ? You need the exponent modulo 4. Since modulo 4 and is an odd power, the exponent is modulo 4. So the last digit is that of , which is 3.
Follow-up. Which digits have a period shorter than 4? The digits 0, 1, 5 and 6 stay fixed, and 4 and 9 have period 2. The digits 2, 3, 7 and 8 have period 4.
Question 6.4 ★ QR, QT, Trader, QD, Dev • any • junior
A corridor has 1000 closed doors, numbered 1 to 1000. For each from 1 to 1000, a person walks past and changes the state of every door whose number is a multiple of . How many doors are open at the end? How many times is door 72 changed?
Answer
Answer to Question 6.4.
31 doors are open, and door 72 is changed 12 times.
Door is changed once for each divisor of . Divisors come in pairs, and , so the count is even unless the two members of a pair coincide, which happens only for a perfect square. So the open doors are the perfect squares up to 1000: up to , since .
For door 72, write . A divisor chooses a power of 2 from 4 options and a power of 3 from 3, so there are . Being even, door 72 ends closed.
Classic wrong answer. Guessing that half the doors end open, as if each one were a coin toss. The number of changes is entirely decided by the door’s divisors.
Follow-up. Which door below 1000 is changed most often? Door 840, which has 32 divisors, more than any other number below 1000. It ends closed.
Question 6.5 ★ QR, QT, Trader • any • junior
Take any three-digit number and write it twice to make a six-digit number, as in 123123. Why is the result always divisible by 7, 11 and 13?
Answer
Answer to Question 6.5.
Writing a number twice gives , and .
Writing three places to the left and adding is the same as . For example, . Dividing by 7, then 11, then 13 gives back .
Follow-up. How does this give a test for divisibility by 7? Since modulo 1001, and so modulo 7, split a number into blocks of three digits from the right, and take the alternating sum. For the sum is , which leaves remainder 4 on division by 7, and so does . The same test works for 11 and 13.
Follow-up. What does writing a two-digit number twice do? It multiplies by 101, which is prime. So .
Classic wrong answer. Trying examples until you see a pattern. Examples will convince you, but the question asks why, and only the factor of 1001 explains it.
Question 6.6 ★ QR, QT, Trader • any • junior
What is the smallest positive whole number that leaves remainder 1 when divided by 2, remainder 2 when divided by 3, and so on up to remainder 9 when divided by 10?
Answer
Answer to Question 6.6.
The number is 2519.
In each case the remainder is one less than the divisor. So the number plus 1 is divisible by every from 2 to 10, and the smallest such number plus 1 is the least common multiple: . So the number is 2519.
Classic wrong answer. Answering . That does satisfy every condition, but it is not the smallest: the factorial counts repeated factors that the least common multiple does not need.
Follow-up. And up to 20? The least common multiple adds the primes 11, 13, 17 and 19 and one more power of 2: . So the number is .
Question 6.7 ★★ QR, QT, Trader, QD • any • junior
How many zeros does end in when it is written in base 12?
Answer
Answer to Question 6.7.
ends in 8 zeros in base 12.
A trailing zero in base 12 is a factor of 12, which is . Count both primes with Legendre’s formula. For 2: . For 3: . Each factor of 12 uses two 2s and one 3, so 2s allow factors of 12, and 3s allow 8. The smaller count wins, so 8 zeros.
Classic wrong answer. Trusting the base-10 habit of counting only the larger prime. It happens to give 8 here, but you must compare the count of each prime against its exponent in 12, because the limiting prime is not always the larger one. For example, has seven 2s and four 3s, so it ends in 3 zeros in base 12, limited by the 2s, and not in 4.
Follow-up. What about base 6 and base 10? Base 6 needs a 2 and a 3 per zero, so . Base 10 needs a 2 and a 5, so .
Question 6.8 ★★ QR, QT, Trader • any • junior
The five-digit number , with digits and , is divisible by 72. Find and .
Answer
Answer to Question 6.8.
and , so the number is 43272.
Split 72 into its coprime factors, 8 and 9, and use a separate test for each. Divisibility by 8 depends only on the last three digits, . Among 270 to 279, only 272 is a multiple of 8, so . Divisibility by 9 depends on the digit sum, , which must be a multiple of 9, so . Check: .
Classic wrong answer. Testing multiples of 72, of which there are too many. Use only coprime factors: 72 is , not , because a number can be a multiple of both 6 and 12 without being a multiple of 72.
Follow-up. Is the answer always unique? No. For , may be 0 or 8, and these give 72360 and 73368. Check every candidate before you stop.
Question 6.9 ★★ QR, QT, QD • any • junior
What is the remainder when is divided by 17? Work it out by hand.
Answer
Answer to Question 6.9.
The remainder is 8.
Use the small powers. Modulo 17, , , and . So , which is what Fermat’s little theorem promises for any number not divisible by 17. Now , so
Classic wrong answer. Trying to reduce the exponent modulo 17. The period of powers divides , so you reduce the exponent modulo 16.
Follow-up. Does every base have period 16 here? No. It divides 16. Modulo 17, 3 has period 16, but , so 2 has period 8.
Why it matters. Fast exponentiation and modular arithmetic of this kind are behind hash functions and random-number generators, so a developer may well be asked to code this after working it by hand.
Question 6.10 ★★ QR, QT, Trader • any • junior
A number leaves remainder 1 when divided by each of 2, 3, 4, 5 and 6, and it is divisible by 7. What is the smallest such positive number, and what is the next one?
Answer
Answer to Question 6.10.
The smallest is 301, and the next is 721.
The first five conditions say that is a multiple of , so . Now apply the last condition, modulo 7. Since , you need , which holds at , because . So , which is .
The solutions repeat every . That is the Chinese remainder theorem: with coprime moduli, there is exactly one solution in each full period. The next is therefore 721.
Classic wrong answer. Using as the period, which gives 721 as the smallest. The common multiple is 60, not 720, and 721 is only the second solution.
Follow-up. Solve remainders 2, 3, 2 on division by 3, 5, 7. Numbers with remainder 2 for both 3 and 7 are . Modulo 5 this is , so , and the answer is 23.
Question 6.11 ★★ QR, QT, Trader, QD • market maker, hedge fund • junior
You have unlimited coins worth 7 and worth 11. What is the largest amount that you cannot pay exactly? How many positive amounts can you not pay?
Answer
Answer to Question 6.11.
The largest amount you cannot pay is 59, and there are 30 amounts you cannot pay.
For two coins and with no common factor, the largest unreachable amount is , which is . The count of unreachable amounts is .
Use remainders modulo 7. Using 7s alone moves you up within a remainder class. So in each class you want to know the smallest amount reachable with 11s: these are 0, 11, 22, 33, 44, 55 and 66, one for each remainder. Once a class has been reached, every later amount in it is reachable. The last amount to be missed is just below the largest of these: . Above that, every class has started.
Follow-up. And with coins worth 6 and 9? Their common factor is 3, so no amount that is not a multiple of 3 is ever reachable, and there is no largest unreachable amount.
Classic wrong answer. Multiplying and answering , or thinking that 77 is the first point past which all amounts work. The coins start to cover every class well before 77.
Question 6.12 ★★ QR, QT, Trader, QD, Dev • any • junior
You write out all the whole numbers from 1 to 1000. How many times do you write the digit 1? What is the sum of all the digits of the numbers from 1 to 999?
Answer
Answer to Question 6.12.
You write the digit 1 exactly 301 times, and the digits from 1 to 999 sum to 13 500.
Treat the numbers 0 to 999 as three-digit strings with leading zeros. By symmetry, each digit appears equally often in each place. Each place holds each digit 100 times, so the digit 1 appears times. The number 1000 adds one more, for 301.
For the sum, each place contributes , and three places give . The leading zeros and the number 0 add nothing to it, so including them is harmless.
Classic wrong answer. Counting how many numbers contain a 1. That is a different question: among 0 to 999, the numbers without a 1 number , so 271 contain a 1. With 1000, this makes 272, while a number such as 111 still contributes three digits to the count of 301.
Follow-up. And the digit 0, from 1 to 1000? Now the leading zeros do matter. The answer is 192: 9 in the numbers 10 to 90, 180 in the three-digit numbers, and 3 in 1000.
Question 6.13 ★★ QR, QT, Trader, QD, Dev • any • junior
What is the smallest set of weights, each a whole number of grams, that lets a balance weigh any object of a whole number of grams from 1 to 40, if a weight may go on either pan? How many weights are needed if they may go on only one pan?
Answer
Answer to Question 6.13.
With either pan allowed, four weights are enough: 1, 3, 9 and 27. With one pan, you need six: 1, 2, 4, 8, 16 and 32.
With both pans, each weight has three states: on the object’s pan, on the other pan, or off. So weights give signed sums. These are symmetric about 0, so at most positive values are reachable. For that is 13, which is too few, and for it is 40, exactly enough. The powers of 3 achieve it, as every number has one way of being written in balanced ternary, with digits , 0 and 1. For example, , and .
With one pan, each weight is on or off, so you are writing the number in binary. Five weights reach only 31, and six reach 63.
Classic wrong answer. Answering 1, 2, 4, 8, 16, 32 for both versions. Binary is optimal for one pan, but it wastes the third state.
Follow-up. Which weights are used for 5 grams? : put the 9 on the opposite pan from the object, and the 3 and 1 with the object.
Question 6.14 ★★ QR, QT, QD • any • junior
What are the last two digits of ? Work it out by hand.
Answer
Answer to Question 6.14.
The last two digits are 01.
Work modulo 100 by repeated squaring. , so . Then , and . So the powers of 3 repeat with period 20 modulo 100. Since , .
The general reason is Euler’s theorem: a number coprime to 100 has period dividing . Here the true period is 20, which is shorter.
Classic wrong answer. Thinking that the theorem applies to every base. It needs the base to share no factor with 100.
Follow-up. So what are the last two digits of ? 76. The base 2 shares a factor with 100, so split 100 into 4 and 25. Modulo 4 the power is 0. Modulo 25 the period divides 20, so the power is 1. The only number below 100 that is a multiple of 4 and one more than a multiple of 25 is 76.
Question 6.15 ★★ QR, QT • market maker, hedge fund • junior
Without computing it, what is the highest power of 2 that divides ? What is the highest power of 3? Is divisible by 7?
Answer
Answer to Question 6.15.
The highest power of 2 is , the highest power of 3 is , and 7 does not divide it.
Write , and count each prime with Legendre’s formula. For 2: holds , and holds , so the answer is . For 3: in and in , which leaves . For 7: in and in , which leaves 0.
Kummer’s theorem says this another way: the power of a prime in equals the number of carries when adding and in base . In base 7, 50 is , and adding it to itself gives with no carries, so 7 does not divide it. In base 2, and there are three carries.
Follow-up. Why must the number be even? is always even, as .
Classic wrong answer. Assuming that every prime up to 100 must divide the number, since contains them all. The denominator can cancel every copy, as it does here for 7.
Question 6.16 ★★ QR, QT • any • junior
Show that for every prime greater than 3, is divisible by 24.
Answer
Answer to Question 6.16.
Factor: , and show that 8 and 3 divide this separately.
Since is odd, and are consecutive even numbers. One of them is a multiple of 4, and the other a multiple of 2, so the product is a multiple of 8. Next, among the three consecutive numbers , and one is a multiple of 3. It is not , as is a prime greater than 3, so 3 divides the product. As 8 and 3 are coprime, 24 divides it. For , , and for it is 48, so 24 cannot be replaced by anything larger.
Follow-up. Is primality really needed? No. It uses only that is coprime to 6, so works as well.
Classic wrong answer. Testing 5, 7 and 11 and declaring it proved. Examples show that a claim could be true, and a proof must cover every case.
Follow-up. Is there a similar statement for fourth powers? Yes. For a prime above 5, is a multiple of 240, by the same reasoning with 16, 3 and 5.
Question 6.17 ★★★ QR, QT, Trader, QD • market maker, hedge fund • junior, experienced
Find the four-digit number that becomes its own digits in reverse order when multiplied by 4.
Answer
Answer to Question 6.17.
The number is 2178, since .
Write it as , with . The product has four digits, so is 1 or 2. The product’s last digit is and it is also the last digit of , which is even, so . Then , and must end in 2, which rules out and leaves .
Now expand with and :
This simplifies to . Since , is at most 1. And would make odd, so and . So the number is 2178.
Follow-up. What is the matching number for 9? 1089, since . Putting a 9 in the middle continues the pattern: , and .
Classic wrong answer. Searching through thousands of numbers. The first and last digits pin down and in seconds, and the rest is one line of algebra.
Question 6.18 ★★★ QR, QT, Trader • market maker, hedge fund • junior, experienced
Take every repeating decimal in which , and are three different digits, with zero allowed. What is the sum of all these numbers?
Answer
Answer to Question 6.18.
The sum is 360.
Pair the numbers by symmetry. For take its partner with digits , and . The partner’s digits are also different from one another. The two numbers add to . No number is its own partner, as has no whole-number solution.
The count of such numbers is , which makes 360 pairs, each adding to 1. So the total is 360.
You can check it another way. The value of is . Each digit appears in each place 72 times, and on average the three-digit string is , so the total is .
Classic wrong answer. Trying to sum in the order of the digits. It can be done, but the pairing removes all the arithmetic. If a sum has a symmetry, look for it first.
Follow-up. What about all with ? There are 90, and the same pairing with gives 45 pairs. The sum is 45.
Question 6.19 ★★★ QR, QT, Trader • market maker, hedge fund • junior, experienced
A clock has hour and minute hands of equal length, so you cannot tell them apart, and both move continuously. During one 12-hour cycle, at how many moments are you unable to tell the time from the positions of the hands?
Answer
Answer to Question 6.19.
There are 132 such moments, in 66 pairs.
Measure time in units of 12 hours, so . The hour hand is at of a full turn, and the minute hand at , modulo 1. A reading is ambiguous if swapping the hands also gives a valid time . That means and , modulo 1. Substituting, , so is a whole number. There are 143 such values of : for .
Among these, some have the hands together, so that the swap gives the same time. These are the coincidences, with a whole number, and there are 11 of them. They are not ambiguous. That leaves . Each pairs with a different time that shows the same picture, so they form 66 pairs.
Classic wrong answer. Answering 143. The 11 moments when the hands overlap do show a unique time, since swapping two identical hands in the same place changes nothing.
Follow-up. Is the moment a real example? Yes. It is 5 minutes and about 2 seconds past 12. The hour hand is at of a turn and the minute hand at . Its swap is , which is 1:00:25 or so, where the hour hand is at and the minute hand at .
Question 6.20 ★★★ QR, QT, Trader, QD • market maker, hedge fund • junior, experienced
Boxes hold 6, 9 or 20 items, and you must buy whole boxes. What is the largest number of items that you cannot buy exactly? Prove that every larger number can be bought.
Answer
Answer to Question 6.20.
The largest is 43, and every number above it can be bought.
Work modulo 6. Boxes of 6 let you move up within a remainder class, so you only need the smallest amount in each class that the 9s and 20s can reach:
Here , and . Each is the smallest because reaching a remainder of 1, 2, 4 or 5 needs at least one box of 20, and each extra box of 9 only moves you by 3 modulo 6. So the last missing number is in the class of 49, just below it: . Every number from 44 up lies at or above the smallest amount of its class, so 6s finish it.
Classic wrong answer. Using the two-coin formula on 9 and 20 and answering 151. That is right if no boxes of 6 exist. There is no such simple formula for three coin values, so you must do the table.
Follow-up. What does 44 look like, as a check? , and , , , , . These six in a row, plus 6s, cover all that follow.
Question 6.21 ★★★ QR, QT • market maker, hedge fund • junior, experienced
Which positive whole numbers cannot be written as a sum of two or more consecutive positive whole numbers? Prove it. In how many ways can 2026 be written as such a sum?
Answer
Answer to Question 6.21.
The powers of 2 are exactly the numbers that cannot be written this way. And 2026 can be written in exactly one way: .
Suppose that consecutive numbers starting at add to . Their sum is , so
The two factors have opposite parity, as their difference is , which is odd. The second is larger than . If is a power of 2 then so is , which has no odd factor above 1. So the odd one of the two factors must be 1. But , and the other factor is larger still, so this is impossible.
Otherwise, has an odd factor . Write as a product of the odd part and the even part . Call the smaller one and the larger ; they have opposite parity, so is a whole number, and being the larger makes . Each odd divisor above 1 gives exactly one way. As with 1013 prime, there is one way, with and .
Follow-up. How many ways for 15? Its odd divisors above 1 are 3, 5 and 15, so three ways: , and .
Question 6.22 ★★★ QR, QT, QD, Dev • market maker, hedge fund • junior, experienced
100 people stand in a circle, numbered 1 to 100 in order. Going round the circle from person 1, person 1 stays, person 2 leaves, person 3 stays, person 4 leaves, and so on, always skipping one remaining person and removing the next, until one person is left. Which number is left?
Answer
Answer to Question 6.22.
Person 73 is left.
First take the case where the number of people is a power of 2. Each full pass round the circle removes half the people, and ends just before person 1, so the count starts from person 1 again. So person 1 is left when the count is a power of 2.
Now . After 36 people have gone, 64 remain, and the count has reached the person just after the 36th to leave. The 36th to leave is person 72, so the next to stay is person 73, and from there it is the power-of-2 case with person 73 in the role of person 1.
In general, for with , the survivor is . In binary this moves the leading digit of to the end: is , and that gives , which is 73.
Classic wrong answer. Answering 1 by the power-of-2 argument, which holds only when the count is a power of 2. Here person 1 survives the first two passes. With 25 left the pass ends on a person who stays, and so person 1 leaves first in the next pass.
Follow-up. What if every third person leaves instead? The neat form is lost. Use the recurrence , with people counted from 0. That reaches the number 91 for 100 people, in the numbering of this question.
Question 6.23 ★★★★ QR, QT • market maker, hedge fund • experienced
What is the smallest positive whole number that doubles when its last digit is moved to the front? For example, moving the last digit of 1234 to the front gives 4123. The number may not begin with 0.
Answer
Answer to Question 6.23.
The number is . It has 18 digits, and doubling it gives .
Let the number be , where is the last digit and has digits. Moving to the front gives , and this must equal . So
Since and 19 is prime, 19 must divide . So we need the smallest with modulo 19. Working through the powers of 10 gives .
Then . With this has only 16 digits, which would force a leading zero in . The smallest valid value is , which gives with all 17 digits.
You can also build it by hand from the right: start with last digit 2, and double repeatedly, writing each digit of the product to the left of the last. You stop after writing a 1 with no carry out, because its double is 2, the digit you started from. That is the quickest way to the digits by hand.
Follow-up. Why are these digits familiar? They are the repeating block of written as a decimal.
Follow-up. And for tripling? The same steps with give a 28-digit answer, .
Question 6.24 ★★★★ QR, QT • market maker, hedge fund • experienced
Let be the sum of the decimal digits of . Let be the sum of the digits of , and let be the sum of the digits of . What is ? Find it by hand.
Answer
Answer to Question 6.24.
.
The trick is not to compute the number. Two facts settle it: the sum of digits keeps the remainder modulo 9, and the digit sums shrink very fast.
First, the remainder. modulo 9. Powers of 7 modulo 9 go 7, 4, 1 and repeat, with period 3. Since modulo 3, modulo 9, and so as well.
Next, the size. The number is below , so it has at most digits, and . A number up to that size has six digits at most, and the first of six is 1, so . Up to 46, the largest digit sum belongs to 39, so . The only number up to 12 with remainder 7 on division by 9 is 7.
Classic wrong answer. Assuming that the digit sum of a large power is about a digit and estimating from there. That gives and only roughly, and the remainder is what fixes the answer.
Follow-up. What are the actual values? Direct computation gives , and . Note that is well below its bound, near a digit.
Question 6.25 ★★★★ QR, QT, Trader • market maker, hedge fund • experienced
Five sailors gather a pile of coconuts. During the night each wakes once, in turn. Each divides the pile into five equal shares with one coconut over, gives that coconut to a monkey, hides one share and pushes the other four back into a pile. In the morning the remaining coconuts divide exactly into five equal shares. What is the smallest possible number of coconuts in the original pile?
Answer
Answer to Question 6.25.
The smallest possible number is 3121.
Each sailor takes a pile and leaves . The neat step is to add four ghost coconuts: since , the quantity simply gets multiplied by at each step. So after five sailors,
For this to be whole, must divide , so and the final pile is . The final pile must also divide by 5, and modulo 5, so . The smallest is , which gives .
Check: the piles go , , , , , , and .
The value is the fixed point of the step, since . If negative coconuts were allowed, a pile of would stay forever, and this is what suggests the ghost coconuts.
Classic wrong answer. Working backwards from a guess at the final pile and trying each in turn. It will reach 3121, but you must try many values, and you cannot tell whether you have the smallest.
Follow-up. And if one more coconut goes to the monkey in the morning? The final pile must be one more than a multiple of 5: needs modulo 5, so , which gives .