All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Another Locker Puzzle (Posted on 2006-06-23) Difficulty: 2 of 5
There are N closed lockers numbered 1,2,...., N, each assigned to a different person. The first of these N persons opens all lockers. The second person goes to every second locker and closes them. Then, the third person goes and alters the state of every third locker- that is, opens the locker if closed, or closes it if open. The fourth person alters the state of every fourth locker, and so on, until the last (Nth) person alters the state of just the Nth locker.

At the conclusion of this process, it is observed that the total number of closed lockers is precisely sixty-eight (68) times that of the total number of open lockers, with the total number of open lockers being a prime number.

Determine the value of N. How many lockers end up open?

(Inspired by the lockers problem submitted by Erin.)

See The Solution Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer assist (spoiler) | Comment 2 of 3 |

An earlier version of the below program indicated that the number of open doors for n doors and students is [sqrt(n)] where the square brackets indicate the largest integer not larger than what's inside the brackets. Then the number of closed doors is n - [sqrt(n)] and the ratio of the latter to the former, which we want to come out as 68, is (n-[sqrt(n)])/[sqrt(n)].

To get an idea of the number, treat [sqrt(n)] as if it were sqrt(n). If ((n-sqrt(n))/sqrt(n) is set equal to 68, n would turn out to be 69^2.

n = 69^2 = 4761, leads to 4692 closed doors and 69 open ones, indeed giving the ratio of 68:1, but 69 is not prime.

The floor function complicates the equation so there could be more solutions.  That led to the below program in its current form. It assumes the answer lies somewhere in the vicinity (which had to be expanded for lack of prime number of open lockers closer) of 69^2:

CLS
DEFDBL A-Z
ss = 69 * 69
FOR n = ss - 1200 TO ss + 180
 REDIM lockerClosed(n)
 openCt = n
 FOR p = 2 TO n
   FOR l = p TO n STEP p
    IF lockerClosed(l) THEN
      lockerClosed(l) = 0
      openCt = openCt + 1
    ELSE
      lockerClosed(l) = 1
      openCt = openCt - 1
    END IF
   NEXT
 NEXT
 closedCt = n - openCt
 IF closedCt = 68 * openCt THEN
  PRINT n, openCt, closedCt, closedCt / openCt
 END IF
NEXT

which finds

 4623          67            4556          68
 4692          68            4624          68
 4761          69            4692          68


 
 So, with n = 4623, there are 67 open lockers and 4556 closed ones.


  Posted by Charlie on 2006-06-23 16:18:51
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information