# 319. 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 on if it's off or turning off if it's on). For the ith round, you toggle every i bulb. For the nth round, you only toggle the last bulb.Find how many bulbs are on after n rounds.

Example:

Given n = 3.

At first, the three bulbs are [off, off, off].
After first round, the three bulbs are [on, on, on].
After second round, the three bulbs are [on, off, on].
After third round, the three bulbs are [on, off, off].

So you should return 1, because there is only one bulb is on.


	public static int bulbSwitch(int n) {
return (int)(n >= 0 ? Math.sqrt(n) : 0);
}

#### LeetCode 319. Bulb Switcher 解题报告

2016-10-14 21:36:01

#### [LeetCode]-319. Bulb Switcher (Medium)(Java)

2016-03-01 11:18:32

#### 319. Bulb Switcher LeetCode

2016-02-13 17:55:11

#### leetcode 319. Bulb Switcher

2016-05-25 17:50:05

#### [leetcode] 319. Bulb Switcher

2015-12-19 19:47:18

#### 319. Bulb Switcher**

2017-01-19 21:32:30

#### 【LeetCode】 319. Bulb Switcher

2017-01-10 04:48:39

#### [LeetCode]319. Bulb Switcher

2016-09-17 10:48:31

#### LeetCode 319. Bulb Switcher

2016-02-20 09:13:44

#### [leetcode]319. Bulb Switcher

2016-04-13 20:53:05