Bulb Switcher
There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb.
On the third round, you toggle every third bulb, turning it on if it is off or turning it off if it is on. For the i^th round, you toggle every i bulb. For the n^th round, you only toggle the last bulb.
Return the number of bulbs that are on after n rounds.
Example 1
Input
n = 3Output
1After the three rounds, only the first bulb remains on, so the answer is 1.
Example 2
Input
n = 0Output
0There are no bulbs to turn on, so the answer is 0.
Constraints
- 0 <= n <= 10^9