Skip to main content
Intermediatecoding Verified

N bulbs start off. In round i you toggle every i-th bulb, for rounds 1 to N. Which bulbs are on at the end?

ReportedSource: GeeksforGeeks interview experience: Infosys Specialist Programmer 2025

Quick answerFree

Bulb k flips once per divisor; only perfect squares have an odd divisor count, so bulbs 1, 4, 9, ... stay on; count = floor(sqrt(N)).

Detailed answer· ~130 words

Interview Prep

Unlock the full answer with Interview Prep

Get a ~130-word model answer and a runnable reference solution, plus 28 more Algorithms questions.

Also in Pro (₹499 / 90 days).

Reference solution· runs in the browser sandbox

Interview Prep
Unlock with Interview Prep

+ 28 more Algorithms questions in Interview Prep, each with the full answer.

Discussion