← sunrise Interview Insights

sunrise·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Interviewed for a software engineer role at Sunrise and got hit with a classic math-logic puzzle that I've seen before but still managed to overthink in the moment.

Questions Asked (1)

Q1

There are 100 light bulbs numbered 1 to 100, all starting off. Person i toggles every i-th bulb as they walk past. After all 100 people have gone through, which bulbs are left on and why?

Algorithms & Data Structures
Author's notes

I knew the answer from somewhere in the back of my brain but couldn't articulate why fast enough.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem: each person i toggles bulbs that are multiples of i. Recognize that a bulb ends up on if it is toggled an odd number of times, which happens exactly when it has an odd number of divisors. Conclude that only perfect squares have an odd number of divisors, so the bulbs left on are 1, 4, 9, 16, 25, 36, 49, 64, 81, 100.

Pro tip: Explain the divisor pairing insight: divisors come in pairs (d, n/d), except when n is a perfect square, where the square root is unpaired. This shows why only perfect squares have an odd number of toggles.

1. Clarify the problem

Restate the process: person i toggles every i-th bulb. Confirm that toggling means switching between on and off, and that all bulbs start off.

2. Determine the condition for a bulb to be on

A bulb is toggled once for each divisor of its number. It ends up on if the total number of toggles is odd.

3. Analyze the number of divisors

For most numbers, divisors pair up (e.g., 2 and 3 for 6), giving an even count. Only perfect squares have an odd number of divisors because their square root is a divisor that pairs with itself.

4. Identify the bulbs left on

The bulbs with an odd number of divisors are the perfect squares up to 100: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100.

5. Summarize the reasoning

Conclude that these 10 bulbs are on because they are toggled an odd number of times, while all others are toggled an even number of times and remain off.

Key Points to Mention

  • Each bulb is toggled once for each divisor of its number.
  • A bulb's final state depends on the parity of its divisor count.
  • Divisors generally come in pairs (d, n/d).
  • Perfect squares have an unpaired divisor (the square root), making the divisor count odd.
  • The perfect squares up to 100 are 1, 4, 9, 16, 25, 36, 49, 64, 81, 100.
  • There are exactly 10 bulbs left on.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.