There are n bulbs that are initially off. In round 1 you turn on all the bulbs. In round 2 you toggle every second bulb, in round 3 every third bulb, and so on: in round i you toggle every i-th bulb. Round n toggles only the last bulb. Return the number of bulbs that are on after n rounds.
There are n bulbs that are initially off. In round 1 you turn on all the bulbs. In round 2 you toggle every second bulb, in round 3 every third bulb, and so on: in round i you toggle every i-th bulb. Round n toggles only the last bulb. Return the number of bulbs that are on after n rounds.
Example 1:
Input: {"n":3}
Output: 1
Constraints:
0≤n≤109
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":3}
3 bulbs, all off. In round k every k-th bulb is flipped, for k = 1 to 3. How many are on at the end?