Skip to main content
Leetcode_319: Light Bulb Switch

Title

Link: Bulb Switcher

There are initially n bulbs turned off.
In the first round, you turn on all the bulbs. In the second round, you toggle every second bulb. In the third round, you toggle every third bulb (if the bulb is on, turn it off; if it is off, turn it on).
For the i-th round, you toggle every i-th bulb. For the n-th round, you only toggle the last bulb.
Find how many bulbs are on after n rounds.


init-qyAbout 2 minarithmeticleetcodearithmetic