sddd1
Member
- Joined
- Jul 22, 2021
- Messages
- 14
- Programming Experience
- 1-3
There are 500 light bulbs (numbered 1 to 500) arranged in a row. Initially they are all OFF. Starting with bulb 2, all even numbered bulbs are turned ON. Next, starting with bulb 3, and visiting every third bulb, it is turned ON if it is OFF, and it is turned OFF if it is ON. This procedure is repeated for every fourth bulb, then every fifth bulb, and so on up to the 500th bulb. Write a java program to determine which bulbs are OFF at the end of above exercise.