Associated Topics || Dr. Math Home || Search Dr. Math

### A Way to Think about the Locker Problem

Date: 01/16/2004 at 11:24:20
From: michael
Subject: locker problem

Imagine there is an endless string of lockers in your school.

Person 1 starts at locker 1 and opens every locker.
Person 2 starts at locker 2 and closes every 2nd locker.
Person 3 starts at locker 3 and changes every 3rd locker.
Person 4 starts at locker 4 and changes every 4th locker.
Person x starts at locker x and changes every xth locker.

I need to figure out which lockers are left open in a row of 25,
100, and a row of 500 lockers.

I have been trying to figure this out for 4 days and my parents can
not figure it out either.  I don't know what number person x is.  My
parents say this has nothing to do with math.  Can you help?

Date: 01/16/2004 at 12:19:02
From: Doctor Peterson
Subject: Re: locker problem

Hi, Michael.

It has a lot to do with math!  But I'm not sure whether everyone your
age can be expected to figure out the complete answer on his own.  You
may be expected only to recognize a pattern, but there is a lot of
very interesting math if you look deep enough.

It sounds like a lot of your confusion is over the 'x' part, so maybe
the problem wasn't made fully clear.  Usually in this problem (it's a
classic, by the way), the number of people is the same as the number
of lockers in the hallway.  So what they mean by 'person x' is all the
people from person 1 up to the last person.  In other words, if there
are 10 lockers there are 10 people, and the pattern continues from
person 1 up through person 10.  If there are 100 lockers, there are
100 people and each of the 100 goes through the hallway turning
lockers that are multiples of their own number.  Does that help?

If I were you, I would first try "playing" with the problem with a
small number of lockers, like 25 so you can see what the whole thing
means.  Here is one way to write it out, but I'll only show 10 lockers:

person #
--------------------
locker #  1 2 3 4 5 6 7 8 9 10
1      +
2      + -
3      +   -
4      + -   +
5      +       -
6      + - +     -
7      +           -
8      + -   +       -
9      +   -           +
10      + -     +         -

I used "+" to mean "opened" and "-" for "closed".

Do you follow what I did, and understand how the problem works?  The
idea is that each person opens or closes only the lockers that are a
multiple of his number: #2 changes the multiples of 2, #3 changes the
multiples of 3, and so on up to person x, the last one to go through.

The only doors left open with 10 lockers are 1, 4, and 9.  One way to
work the problem is to do this with more lockers and look for a
pattern in the numbers of the lockers left open; a better way is to
look for a REASON why there should be a pattern.  What is it that
makes one locker end up open and another end up closed?

Notice that each time a locker is "touched" it changes from open to
closed or vice versa.  So in order to end up open, it has to be
touched an odd number of times.  Now, what might make that happen?

A key is to realize that the whole problem is about multiples and
divisors.  Do you see why?  That's where the math comes in!

If you have any further questions, feel free to write back.  Good luck!

- Doctor Peterson, The Math Forum
http://mathforum.org/dr.math/
Associated Topics:
High School Number Theory
High School Puzzles

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search