← Sunrise Interview Insights

Sunrise·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Interviewed for a software engineering role at Sunrise and got hit with a classic math/logic puzzle that I thought I remembered but definitely did not remember as well as I thought.

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 I'd seen this before and that felt like a trap because I half-remembered the answer but not the reasoning.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by reframing the problem: each bulb is toggled once for every divisor of its number. Then determine that a bulb ends up on if and only if it has an odd number of divisors, which happens exactly for perfect squares. Finally, list the perfect squares up to 100 and explain the reasoning clearly.

Pro tip: Mention that this is a classic problem and that the key insight is recognizing the divisor toggling pattern; then generalize to any N by stating the answer is the perfect squares up to N.

1. Restate the problem

Clarify that there are 100 bulbs initially off, and person i toggles bulbs that are multiples of i. The goal is to find which bulbs are on after all 100 people.

2. Identify the toggling pattern

For a given bulb k, it is toggled by person i if and only if i divides k. So the number of toggles equals the number of divisors of k.

3. Determine when a bulb is on

A bulb ends up on if it is toggled an odd number of times. Since most numbers have an even number of divisors, only numbers with an odd number of divisors remain on.

4. Connect odd divisors to perfect squares

A number has an odd number of divisors if and only if it is a perfect square, because divisors pair up except when the number is a square (the square root pairs with itself).

5. List the perfect squares up to 100

The perfect squares from 1 to 100 are 1, 4, 9, 16, 25, 36, 49, 64, 81, 100. These are the bulbs left on.

Key Points to Mention

  • Each bulb is toggled once per divisor of its number.
  • A bulb's final state depends on the parity of its number of divisors.
  • Only perfect squares have an odd number of divisors.
  • The square root divisor is the one that pairs with itself, causing the odd count.
  • The answer for 100 bulbs is the perfect squares up to 100.
  • This reasoning generalizes to any number of bulbs N.

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