A Challenging Divisibility Puzzle: Spoilers

(A new question of the week)

Sometimes we give only minimal help on a question, to let a student puzzle over the problem and learn to figure it out herself. That may be enough, or we may go back and forth for some time, guiding her thinking until she finds the answer. In the latter case, do we put the whole discussion in our archive, so the answer is given away along with all the thinking? Or do we archive only hints? Recently a student wrote to ask about the answer to a puzzle we didn’t work to the end, and the discussion gives some interesting insights into the process — so here come the spoilers.

The problem

First, here is the question from our archive, asked by 12-year-old Subby in 2015:

All in a Row: Divisible Except for One Consecutive Pair

In a class, 25 students were lined up. 

The teacher wrote a number on the board.

The first student said the number was divisible by 1.

Student number 2 said it was divisible by 2.

Student 3 said it was divisible by 3.

This went on until the 25th student.

The teacher said everyone was correct except two boys, named Ben and
Danny, who were wrong. They were standing one after the other in the line.

What are their positions in the line?

Not sure if I have to find a common factor between 1 and 25, then divide
the found number by each number between 2 and 25 to see who has divided
correctly.

I think I am not approaching this right.

Doctor Greenie answered this, restating the problem and giving some hints:

This is a terrific problem -- quite challenging, I would think, for a 12-year-old.

According to the problem description, there are two consecutive numbers from 1 to 25 which do not evenly divide the teacher's number; and they are the only two numbers that do not divide the teacher's number.

The key to solving the problem is to look at divisibility rules for the numbers 1 to 25. 

For a couple of examples:

   25 = 5^2
            since the only prime factor of 25 is 5,
            we can't relate divisibility by 25 to
            divisibility by any smaller numbers

   24 = (2^3)*3 = 8*3
            the number is divisible by 24 if it is
            divisible by both 8 and 3

   23 is prime
            we can't relate divisibility by 23 to 
            divisibility by any numbers smaller than 23

   22 = 2*11
            the number is divisible by 22 if it is
            divisible by both 2 and 11

Continue this list down to 1; there will only be one place where it is not possible to relate the divisibility rules for two consecutive numbers to divisibility rules for smaller numbers.

Those two consecutive numbers are Ben's and Danny's places in the line.

The hint was (intentionally, I assume) not very detailed; a year later, another student wrote to ask about it, focusing too much on the rules for recognizing when a number is divisible by another, such as that “a number is divisible by 3 if the sum of its digits is divisible by 3”. That type of rule was not what Doctor Greenie emphasized; but rather, others, like “a number is divisible by 6 if it is divisible by both 3 and 2”, which is a particular case of a very general rule. I responded with some more specific hints:

I think you are misinterpreting what Doctor Greenie said. I imagine he deliberately kept his hint rather cryptic to avoid spoiling it for others. (For that matter, I'm not sure I follow his hint completely, myself!)

What I would say is that, rather than get caught up in the details of the divisibility rules, you want to consider just the relationships that some of them imply -- the rules like yours for 6. This rule implies two things:

1. If 6 does NOT evenly divide the number, then either 2 or 3 must also NOT be a divisor (since if both did divide it, 6 would also); since 2 or 3 and 6 are not consecutive, 6 can't be one of the two non-divisors.

2. If either 2 or 3 does NOT evenly divide the number, then 6 must also NOT be a divisor (since if 6 were a divisor, then both 2 and 3 would be too); so neither 2 nor 3 can be one of the two non-divisors.

Look for this sort of relationship among other sets of numbers. You might need to make a table or diagram showing these connections, or it may be enough to cross off from a list each number that is excluded. You should soon get a feel for what kind of numbers one of the pair has to be, and then discover what the other one must be.

Doctor Greenie also responded, saying he had trouble understanding his own hint (which is not uncommon, when we look back at our own old answers!), and adding more:

The input that Doctor Peterson gave is important. Where you were looking at the divisibility rules in isolation, the thing you want to be looking at is the relationship between the divisibility rules.

For example, a number is divisible by 24 if it is divisible by both 3 and 8; a number is divisible by 14 if it is divisible by both 2 and 7.

Note in that first example, it is important to say a number is divisible by 24 if and only if it is divisible by both 8 and 3. It would not be sufficient to say it is divisible by 24 if it is divisible by 4 and 6. 4 times 6 is 24; but 4 and 6 have a common factor of 2. 12 is divisible by 4 and 6; but it is not divisible by 24.

So if 24 were one of the two numbers that did not divide the teacher's number, then it would not be divisible by 3 or 8 either. But then you have numbers that are neither consecutive nor divisors of the teacher's number. So 24 can't be one of the two consecutive non-divisors.

What about 23? It is prime, so having a number divisible by 23 does not imply divisibility by any smaller number. There is a possibility that 23 is one of the two consecutive non-divisors.

But we already know that 24 can't be one of the two non-divisors; and divisibility by 22 implies divisibility by both 2 and 11. So even though 23 had the possibility of being one of the two non-divisors, each of its neighbors can't be the other one.

Similarly, we can rule out 22, 21, and 20 as being one of the two consecutive non-divisors, because for each of them divisibility implies divisibility by smaller numbers that are not adjacent:

   non-divisibility by 22 --> non-divisibility by 2 or 11
   non-divisibility by 21 --> non-divisibility by 3 or 7
   non-divisibility by 20 --> non-divisibility by 4 or 5

Continue down the list to find the only place where non-divisibility by two consecutive numbers does *not* imply non-divisibility by any smaller numbers.

In the process of trying to provide an explanation that could help you solve the problem, I came up with this alternative method, which you might (or might not!) find easier. Start by finding the smallest number (in prime factorization form) of the number that is divisible by all the numbers from 1 to 25. Then search for ways to remove certain prime factors so that two consecutive integers become non-divisors.

More help

Now, this summer, Sarah got interested in solving this, and wrote to us for help:

I found this in the Ask Dr.Math archives, and got curious what the solution is: http://mathforum.org/library/drmath/view/77746.html. After reading the hints, I thought the obvious answer is 2 and 3, since they’re both prime? Is this correct? And how would you find the actual number the teacher wrote? (Out of curiosity and as a check)

We went back and forth on this for four days (partly due to being in distant time zones). I first corrected her attempt:

No, the answer can’t be 2 and 3; as I said in my answer,

If either 2 or 3 does NOT evenly divide the number, then 6 must also NOT be a divisor (since if 6 were a divisor, then both 2 and 3 would be too); so neither 2 nor 3 can be one of the two non-divisors.

What we know is that every integer from 1 through 25 is a divisor of N except for two consecutive numbers. If nothing else, you could just try every pair from 1,2 to 24,25 and think about the implications; along the way, you might get some special insight. But I will tell you that my immediate thought (which could be wrong) is that the pair of non-divisors might more likely be large than small. The 2,3 case shows why, and this may be why Dr. Greenie started his list at 25.

Give it another try. I’ll be thinking about it while you do. (I don’t immediately recall what the answer was.)

She gave it a try that didn’t work, and I responded with further clarification:

Let’s look more closely.

We want to find two consecutive numbers such that our unknown number N can be a multiple of every number from 1 to 25 except those two.

Suppose the answer were 24 and 25. That would mean that N is a multiple of everything up to 23, but not of 24 or 25.

First, consider 25 = 5^2. If N were a multiple of 25, then it would also be a multiple of 5; that doesn’t matter (just now). But if N is not a multiple of 25, it can still be a multiple of 5 (e.g. 35), so there is no problem. None of the other numbers is forced to be a divisor of N by this fact. We might call 25 a “safe” number.

But consider 24 = 2^3 * 3. If N were a multiple of 24, then it would also be a multiple of any divisor of 24 (1, 2, 3, 4, 6, 8, 12). But what matters to us at the moment is the implication if N is not a multiple of 24.

We can split 24 into 3*8, where 3 and 8 have no common factors; then we know that if N is a multiple of both 3 and 8, it must be a multiple of 24. Do you see why? This is fundamental to divisibility checks, and would not be true if we chose a pair of numbers with a common factor, like 4 and 6: 12 is a multiple of both, but not of 24.

Now, the contrapositive of that statement in bold is, if N is not a multiple of 24, then it must not be a multiple of both 3 and 8; that is, it must either not be a multiple of 3, or not be a multiple of 8. But we were supposing that 24 and 25 are the only numbers from 1 to 24 of which N is not a multiple. So 24 can’t be one of the numbers we’re looking for. We might say that 24 is not a “safe” number.

Now, I mentioned some facts that we don’t care about yet (with 24 or 25); they will come into play when we look at smaller numbers. For instance, if N were not a multiple of 2, then it couldn’t be a multiple of any multiple of 2 either. That would give us a lot of other numbers from 1 to 25 that N was not a multiple of, so 2 can’t be one of our numbers: it is not “safe”.

What I did to solve the problem was to look individually at each number from 1 to 25 and do thinking like I just did: what other facts would be implied if N were not a multiple of a given n? If n not being a divisor implies that any other numbers than n-1 and n+1 are also not divisors, then n can’t be it. Eventually, you should be able to speed up a bit, by noticing certain kinds of numbers that are “safe”. I’m deliberately avoiding some words that would give you too much of a hint!

My introduction of a made-up term, “safe” (by which I meant that it doesn’t “endanger” other numbers), is a common trick of mathematicians to make it easier to talk about a concept that is useful in a particular problem. I think of this as a “local definition”. A common word that is used is “nice”, which in ordinary usage has only a vague positive meaning, and so, like tofu, can be given whatever specific flavor you want. Here, it lets me state the goal quickly: We want to find two consecutive safe numbers.

Sarah gave me a lot of detail on her next try:

I understand what you said, but I’m not sure I know how to continue. I was probably mixing up factors and multiples, even though I know the difference between the two. I’m guessing that by certain kinds of numbers you meant the primes, but thanks for not giving too many hints; it’s good to do some thinking!

Let me try:

If N is not a multiple of 23 – 23 is prime, so it’s “safe”

If N is not a multiple of 22 – it can’t be a multiple of both 2 and 11 so it’s not “safe”

If N is not a multiple of 21 – it can’t be a multiple of both 3 and 7, so its not “safe”

If N is not a multiple of 20 – it can’t be a multiple of both 4 and 5, or both 2 and 10, so it’s not “safe”

If N is not a multiple of 19 – 19 is prime, so it’s “safe”

If N is not a multiple of 18 –  it can’t be a multiple of both 3 and 6, or both 2 and 9, so it’s not “safe”

If N is not a multiple of 17 – 17 is prime, so it’s “safe”

If N is not a multiple of 16 – it can’t be a multiple of both 2 and 8, so it’s not “safe”

If N is not a multiple of 15 – it can’t be a multiple of both 3 and 5, so it’s not “safe”

If N is not a multiple of 14 – it can’t be a multiple of both 2 and 7, and 28 can’t be a multiple, so it’s not “safe”

If N is not a multiple of 13 – 26 can’t be a multiple either

If N is not a multiple of 12 – it can’t be a multiple of both 4 and 6,  and 24 can’t be a multiple, so it’s not “safe”

If N is not a multiple of 11 – it can’t be a multiple of 22

If N is not a multiple of 10 – it can’t be a multiple of both 2 and 5

If N is not a multiple of 9 – then 18 cannot be a multiple, and N can’t be a multiple of 3

If N is not a multiple of 8 – it can’t be a multiple of both 2 and 4

If N is not a multiple of 7 – 14 can’t be a multiple, and neither can 21

If N is not a multiple of 6 – it can’t be a multiple of both 2 and 3

If N is not a multiple of 5 – 10, 15, 20, and 25 can’t be multiples either

If N is not a multiple of 4 – 8, 12, 16, 20, and 24 can’t be multiples either

We’ve already ruled out 2 and 3, and 1 obviously can’t be, since every number is divisible by 1.

Spoiler alert!

She was very close now. My reply:

Primes were one of two kinds of numbers I could have mentioned. Certainly they are always “safe”. (Or not? Comment below.)

So you’ve listed these numbers as “safe”: (By the way, I first used that term just on a whim as I was typing, but I now see how good an idea it is!)

17, 19, 23

I’d also listed 25 as safe.

I see that for 14 and 13, you mentioned numbers greater than 25; you might want to reconsider. That will be a significant change in the way you have to think once you get to smaller numbers. But you were still thinking, because you saw that 11, though prime, is not safe, because 22 is less than 25. So we should say that primes greater than 13 are safe.

The main problem is that you didn’t take to heart my comment about the importance of “factors with common factors”. For 18, you say “it can’t be a multiple of both 3 and 6, or both 2 and 9, so it’s not “safe”. That’s correct for 2 and 9, which are relatively prime (I can use that word now), but not for 3 and 6. Since these have a common factor, 3, a number can be a multiple of both but not be a multiple of their product: 12 is a multiple of 3 and of 6, but not of 18. So you can’t say that if N is not a multiple of 18, then it can’t be a multiple of both 3 and 6. (This was part of what Dr. Greenie had in mind about divisibility rules.)

The main thing you need to do is to work through things a little more slowly, and perhaps do as I had not done and write explicit statements like “primes greater than 13 are safe” so you can check them out. But I’ll give you one more specific hint: you know why that latter fact is true (well, check it out!); what is it that makes 25 safe? It isn’t prime! Is it just being the highest number in the list, or is there more to it?

Sarah’s next attempt:

This is very interesting! I also like the idea of defining safe numbers!

My first thought about 25 is that it is safe because it is a square number, so I’m thinking the solution is 16 (square number) and 17 (prime greater than 13). Let’s check it out:

16 is 2 * 8, and 2 is a common factor, so I can’t say that if N is not a multiple of 16, it can’t be a multiple of both 2 and 8. (In this case, I can’t find a number that is a multiple of both 2 and 8, but not of 16). If N is not a multiple of 16, it can be a multiple of 4 though.

We’ve already said 17 is a safe number.

I’ve just reread what you wrote about 25, and realised that you wrote “consider 25 = 5^2”, so it was there in front of me! Nice hint 🙂

But let’s check another example, to be sure:

9 – if N is not a multiple of 9, it can be a multiple of 3 (example 6)

So think the answer is 16 and 17.

Also, I don’t think 18 is safe, since it can’t be a multiple of both 2 and 9. Otherwise, the answer would have been there already – 17 and 18.

The reference to 25 = 5^2 was not intended as a hint; I was showing the factors of everything. But it did make the key idea visible.

I answered:

Elaborating on what you said about 16, the general idea is to look at the prime factorization of a number, in this case 2^4. With only one prime factor, there is no pair of factors (other than 1 and 16) that are relatively prime; so the only conclusion regarding smaller numbers is that if 16 is a divisor of N, then every lower power of 2 is a divisor of N (2, 4, 8). Given that 16 is not a divisor of N, we can’t conclude that any lower number must not be a divisor of N. Also, since 2*16> 25, we can’t conclude that any larger number must not be a divisor of N. Thus we can conclude that 16 is safe. (You said, “I can’t find a number that is a multiple of both 2 and 8, but not of 16”; did you try 8?)

Your answer is correct.

Now, notice how much more has to be said than I said explicitly last time:

We define a safe number as a positive integer n such that, if n is not a divisor of some number N, then no other number in {1, 2, .., 25} is necessarily not a divisor of N.

Whether a number is safe depends on two things: whether there are any smaller numbers that are forced not to be divisors, and whether there are any larger numbers up to 25 that are forced not to be divisors. These work in different ways, and must both be considered.

No number less than 13 can be safe, because doubling it will yield a number less than 26.

Any prime n greater than or equal to 13 is safe, because no smaller number (except 1) is a factor of n, and no larger number through 25 is a multiple of n.

Any prime power n greater than or equal to 13 is safe, because there are no pairs of relatively prime numbers that are both factors of n.

After this, we discussed a similar problem I had run across with some interesting differences. But this post is already over my self-imposed size limit …

6 thoughts on “A Challenging Divisibility Puzzle: Spoilers”

  1. Hello everyone.
    I think you all are making this problem way too complicated. Its rather an easy one. Approach using prime-factorization:

    1 = 1
    2 = 2
    3 = 3
    4 = 2*2
    5 = 5
    6 = 2*3
    7 = 7
    8 = 2*2*2
    9 = 3*3
    10 = 2*5
    11 = 11
    12 = 2*2*3
    13 = 13
    14 = 2*7
    15 = 3*5
    16 = 2*2*2*2
    17 = 17
    18 = 2*3*3
    19 = 19
    20 = 2*2*5
    21 = 3*7
    22 = 2*11
    23 = 23
    24 = 2*2*2*3
    25 = 5*5

    Now, take maximum common prime factors, we get: 1*2*2*2*3*3*5*5*7*11*13*19*23 = 787,386,600

    Look carefully at the above number. It is divisible by all numbers between 1 to 25 except 16 and 17.

    Simple!

    By,
    Amey Jain
    India

    1. Hi, Amey.

      I don’t see how this solves the problem.

      You say, “take maximum common prime factors”, but somehow you didn’t include 17 or a fourth 2 as prime factors. Why not?

      The problem is not to find the large number (LCM), but to find which two consecutive numbers are not divisors of it, and nothing you have said suggests how to choose them without already knowing which two to exclude.

      1. I like the LCM approach.

        The LCM is 2^4 x 3^2 x 5^2 x 7 x 11 x 13 x 17 x 19 x 23, which is essentially products of exponents of primes less than 25. Our job now is to take off the minimum number of factors off this list, so as to give us two consecutive numbers that the LCM can no longer be divided evenly by.

        You cannot take two single-exponent primes off , because the two students have to be in consecutive places. Let’s consider the double-exponent primes. Both those primes are odd. If you took off one of the two exponents for either 3 or 5 (leaving only 3 x 5 in the factorization), it would impact the divisibility by 9 or 25, respectively. BOTH those integers stand next to EVEN integers, whose divisibility cannot be impacted without removing at least one exponent of 2, which we cannot touch (because EXACTLY 2 students are wrong, not more).

        You are now left with only one prime factor. The bizarre black sheep of the prime family – the only even prime number with a whim of its own: 2. The highest exponent of 2 in the factorization is 2^4, which stands right next to another PRIME number!

        In other words, those are the two factors that you need to impact: 2^4 and 17. You impact the divisibility of 2^4 by taking off only one exponent, and leaving 2^3 in the factorization, thereby NOT impacting the divisibility by any other integer. And finally, you impact the divisibility of 17 by taking it off the factorization.

        In other words, divide the LCM of 1, 2, 3, 4, ….., 24, and 25 by (2 x 17), and you get the number the teacher oh so cruelly wrote on the board in a classroom of 12-year-olds!

        1. Hi, Bhaskar.

          I like the approach of removing factors, starting from the LCM of all the numbers from 1 through 25.

          Before I talk about the details, I have to point out some issues of terminology; I couldn’t follow your explanation until I figured out that you are using some words differently than I do.

          What you call “exponents of primes”, I call “powers of primes”. That is, you are not talking about just the 4 in \(2^4\), but the entire expression. I see many people call exponents “powers” (e.g. “the power of 2 in \(2^4\) is 4”), but not calling powers “exponents”. Then, what you call “single-exponent primes” I would call just “primes”, and your “double-exponent primes” I would call “squares of primes”.

          Having figured that out, your reasoning looks good; I can’t say for sure that it would be quite as easy as it looks to do this without already having an idea of the answer. It might be interesting to modify the story a little (maybe just increasing the size limit on the factors?) and see if you can solve the new problem — with the recognition that the new problem may not have a solution!

          Your last comment raises an interesting thought: The problem involves a story in which a class (age not indicated) are just given the task of determining divisibility of this large number (787,386,600, if I’ve got it right), by one divisor each (presumably by doing one division); so there is nothing cruel about writing that number on the board. But is a 12-year-old (outside of the story!) expected to solve this problem? I’ve wondered if Subby might have entered her grade, rather than her age, into our form, so this might have really been aimed at 12th graders. And we aren’t told that the problem itself was given to a class at all; it may well come from a book of challenging puzzles! And it’s never cruel to give a challenge to someone (of any age) willing to take it on.

          1. Dear Dr. Peterson,

            You are right, sir, my terminologies are in error. I do mean what you hypothesize I mean. I’m not a serious math enthusiast at all, quite the opposite, actually, if I may say so! I stumbled upon this page when I was looking for a problem to present to my 10-yo son who I am trying to teach divisibility rules. I got hooked on to the problem, because it’s an interesting one. By profession though, I write novels and movies, sir 🙂 Which also probably explains my sarcasm about the cruelty of the teacher. Just a dash of banter.

            I did think about the problem a bit more, and one question kept haunting me. Why 25? I tried to generalize the problem and it seemed to me that it is possible that this is a word-based problem for the mathematical question (working backward, of course): What are the positive values of n, for which 2^(2^n) + 1 is a prime number? In this specific case, we are dealing with n=2. That rang a bell about something that I had read when I was in college many autumns ago. A little research on the internet confirmed my suspicions. 2^(2^n) + 1 is Fermat’s number, and apparently, there aren’t too many KNOWN Fermat’s numbers that are also prime. I wondered what would have happened if there would have been 10 students in the class. Would Ben and Danny be then standing in the 4th and 5th positions in that case? If I remove 5 from the LCM of 1, 2, 3, 4, ….., 9 and 10, then the number that remains is not only not divisible by 5, it is also not divisible by 10. That doesn’t help us. No more so, than if there would have been, let’s say, 34 students in Subby’s problem. We are able to remove 17 only because there is no other positive multiple of 17 that we need worry about. I wonder if I’m correct in thinking that way.

            The other question that comes to mind, when I stumbled upon the notion of Fermat’s numbers, is the simple question: what about the numbers 2^(2^n) – 1? Can they be prime? We know for sure that it is true for n=1. But it seems to me that for every value of n > 1, this number can be written as the difference of two squares, and can therefore be written as (a + b)(a – b). Therefore, that number cannot be prime, and therefore, it wouldn’t help our crusade of finding where Ben and Danny stand.

            My original question still remains though. Is (16, 17) the ONLY solution to Subby’s original problem? I wonder.

  2. I would start with these 2 keys:
    Key #1: the numbers cannot be 12 or less because each of those numbers have a multiple less than 25
    Key #2: each of the 2 numbers cannot have more than one prime factors.
    Because of key #2, one of the 2 numbers must be a perfect square between 13 and 25, and the other number must be a prime.
    That makes 16-17 is the answer.

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.