You are on page 1of 5

MaryNewman Math311M WritingProject TheLockerProblem TheLockerProblemisaclassicexampleinnumbertheorydealingwithfactorization.It goesasfollows:Therearenlockedlockers,L1...Ln,inahallway,andnstudents,S1...Sn.Alln studentsgothroughandchangethestatusofeachlockerthatisdivisiblebytheirordernumber. Forinstance,thefirststudentunlockseverylocker.Thesecondstudentthenlockseveryother locker.Thethirdstudentgoesthroughandchangesthestatus(locked/unlocked)ofeverythird locker,thefourthstudentdoesthesameforeveryfourthlocker,andsoonuntilallnstudents havegone.TheLockerProblemasks,whichlockerswillbelockedandwhichwillbeunlocked afterallofthestudentshavegone?And,whathappensiftheorderofthestudentschanges? Beforewetrytodrawanyconclusions,wecanlookatanexampleofasmallnumberof lockers.Supposethereare10lockers(L1,...,L10)and10students(S1,...,S10).

Wecando TheLockerProblemforthisexampleourselvesbylettingeachstudentchangethestatusoftheir lockers.Table1showsthisprocessclearly.Alllockersstartlocked.Everystudentthenchanges thestatusoftheirlockersoneaftertheother.Afterall10studentshavefinishedgoingthrough eachlocker,allarelockedexceptforlockersone,fourandnine.

Table1.Changedstatusof10lockersaftereachstudent
(changedstatusesseeninred)

S1 S2 S3 S4 S5 S6 S7 S8 S9 S10

L1
lock unlock unlock unlock unlock unlock unlock unlock unlock unlock unlock

L2
lock unlock lock lock lock lock lock lock lock lock lock

L3
lock unlock unlock lock lock lock lock lock lock lock lock

L4
lock unlock lock lock unlock unlock unlock unlock unlock unlock unlock

L5
lock unlock unlock unlock unlock lock lock lock lock lock lock

L6
lock unlock lock unlock unlock unlock lock lock lock lock lock

L7
lock unlock unlock unlock unlock unlock unlock lock lock lock lock

L8
lock unlock lock lock unlock unlock unlock unlock lock lock lock

L9
lock unlock unlock lock lock lock lock lock lock unlock unlock

L10
lock unlock lock lock lock unlock unlock unlock unlock lock lock

Whyisthistheresult?Whatdolockersone,four,andninehaveincommon?Andwhatif therewereadifferentnumberoflockersorstudents?Tofindtheanswerstothesequestions, weneedtothinkaboutwhatcausesalockertoenduplockedorunlocked.Atthebeginning, eachlockerislocked.Ifalockergetsunlocked,itneedstogothroughasleastonemorestatus changetoenduplocked.Therefore,aslongastherearetwo,oramultipleoftwo,status changes,thelockerwillenduplocked.Solockerswithanumberofstatuschangesoftheform 2k,wherekissomeinteger,orinotherwordsanevennumberofstatuschanges,willbelocked aftereachstudentgoes.Theoppositeistrueforendingunlocked.Toendupunlocked,alocked lockermustgothroughonemorestatuschange,andthereforethenumberofstatuschanges willbeoftheform2k+1,orodd. ThispatternisveryeasilyseeninTable1.Wecancounthowmanytimeseachlocker

changesstatusbycountingtheredstatusesineachcolumnofTable1.Thesecountsare displayedinTable2.Lockersone,fourandninegothroughone,threeandthreechanges respectively,eachodd.Therestofthelockersgothroughanevennumberofstatuschanges. Table2.Numberofstatuschanges Numberofstatus changes L1 1 L2 2 L3 2 L4 3 L5 2 L6 4 L7 2 L8 4 L9 3 L10 4

(redindicatesoddchanges)

Howdoesthishelpusgetclosertosolvingthelockerproblem?Thestatusofalockeris changedeachtimeastudentsnumberisafactorofthelockersnumber.Thismeansthatthe numberoffactorseachlockernumberhasisthenumberofstatuschangesitgoesthrough. Therefore,alockernumberwithanevennumberoffactorswillenduplocked,andalocker numberwithanoddnumberoffactorswillendupunlocked.LookingatourexampleinTable1, numbersone,four,andnineeachhaveanoddnumberoffactors,anddoinfactendup unlocked. Whydothesenumbershaveanoddnumberoffactors?Afactorisanumberthatdivides itsmultiplewithoutaremainder.Thequotientisitsmatchingfactor,andisalsoafactorofthe multiple.Bydefinition,everyfactorhasamatchingfactorsuchthattheproductofthetwoisthe multiple.Thiswouldimplyanevennumberoffactors,exceptinthecasewhenthematching factorisitself.Whenanumbercanbedividedbyafactortogetthesamefactor,thefactoris calledthesquareroot.Forinstance,fourdividedbytwoistwoandninedividedbythreeisthree. Twoandthreearethesquarerootsoffourandninerespectively.Everymultiplewithaninteger squareroothasanoddnumberoffactors,sincethesquarerootisitsownmatchingfactor.

Ergo,squarelockernumberswillhavetheirstatuschangedanoddnumberoftimesandthus willbeleftunlocked. Ourexamplesupportsthis,asone,fourandnineareallsquare,however,weareno longerlimitedtojusttenlockers.Weknowthesquarenumberswillbeunlockedforanynumber oflockers.Wealsoknowthattheorderinwhichthestudentsgodoesnotmatter.IfS2changes everyotherlockerbeforeS1changesallofthem,orifS6changeseverysixthlockerbeforeS3 changeseverythird,thesquareswillstillbeunlockedaftereverystudentgoes.Itdoesnotmatter whatorderthestudentsgoinitonlymatterhowmanyfactorseachlockernumberhas. Forexample,whatifthestudentsgobackwards?WecanseeinTable3thattheresults forourexamplearethesame.Alllockersenduplockedexceptforthesquares,lockersone, four,andnine. Table3.Changedlockerstatus,studentsgobackwards
S10 S9 S8 S7 S6 S5 S4 S3 S2 S1 L1
lock lock lock lock lock lock lock lock lock lock unlock

L2
lock lock lock lock lock lock lock lock lock unlock lock

L3
lock lock lock lock lock lock lock lock unlock unlock lock

L4
lock lock lock lock lock lock lock unlock unlock lock unlock

L5
lock lock lock lock lock lock unlock unlock unlock unlock lock

L6
lock lock lock lock lock unlock unlock unlock lock unlock lock

L7
lock lock lock lock unlock unlock unlock unlock unlock unlock lock

L8
lock lock lock unlock unlock unlock unlock lock lock unlock lock

L9
lock lock unlock unlock unlock unlock unlock unlock lock lock unlock

L10
lock unlock unlock unlock unlock unlock lock lock lock unlock lock

TheLockerProblemboilsdowntohowmanyfactorseachnumberhas.Ifthereisanodd numberoffactors,implyingthatthenumberhasanintegersquareroot,thenthelockerwillbe unlocked.Ifthereareanevennumberoffactors,implyingthereisnointegersquareroot,then thelockerwillbelocked.Wefindthisbycheckinghowmanytimesalockerischangedand determiningoddchangeswillleavethelockerunlockedwhileevenchangesleaveitlocked.Each changeoccurswhenthestudentsnumberisafactorofthelockersnumber,thuslockerswith anoddnumberoffactorswillbeunlocked.Duetothedefinitionofmatchingfactors,anumber willhaveanoddnumberoffactorsonlyifithasafactorthatisitsownmatchingfactor,whichis anintegersquareroot.Therefore,theanswertoTheLockerProblemissimple.Alllockerswith squarenumberswillbeunlockedafteranynumberofnstudentschangethestatusofalllockers thatareamultipleoftheirnumber,andtherestwillbelocked,regardlessoftheorderofthe students.