There are N light bulbs in a row, numbered 1 through N. Each bulb is either on or off.
There are also N switches, numbered 1 through N. Pressing switch i flips every bulb whose number is a multiple of i: a bulb that was on turns off, and a bulb that was off turns on. You may press the same switch more than once.
Given the current state of the bulbs, write a program that finds the smallest number of switch presses that turns every bulb off.