LAB 3– “20,000 Lights”

[Some of you may have seen this last year and/or know the answer. That is NOT the issue here. The purpose of this assignment is for you to build an algorithm to solve the problem, not write an algorithm to print the answer!]


A room has 20,000 light bulbs, each with its own pull-string. Twenty-thousand people walk into the room, one at a time. The first person pulls each string, turning all the lights on. The second person pulls every second light bulb’s string (the 2nd, 4th, etc.) The third person pulls every third string, the fourth every fourth, and so on. Eventually the twenty-thousandth person pulls the string on the twenty-thousandth light.

A) How many light bulbs are on?
B) Which light bulbs are they?


WHAT I EXPECT
- In the folder called “Labs” create a new project called “Lab1Lights”
- Create an application program called “Lab1Lights”
- All you will need is a main method.

METHODS
- There are a few different ways to answer this problem. We will discuss them.

This lab is worth 20 points. If you can figure out part A, then you should easily be able to get the answer to part B.