Skip to content

Latest commit

 

History

History
10 lines (8 loc) · 273 Bytes

README.md

File metadata and controls

10 lines (8 loc) · 273 Bytes

n is Infinity, so we cannot simulate the process, we should find the rule.

After running the first several thousand cases, we finally find the rule as below:

var bulbSwitch = function(n) {
  var ans = -1 + Math.sqrt(1 + n);
  return Math.ceil(ans);
};