← All questions
MediumCoding
Find Three Consecutive Integers That Sum to a Given Number
Asked at
Google
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Let the middle integer be x.
- 02Write x-1 plus x plus x+1 equals target.
- 03Check divisibility by three.
- 04Construct the three values if feasible.
- 05Handle negative targets and type limits.
Reference answer
Then expect these follow-ups
How does this generalize to five consecutive integers?
Tests: follow-up reasoning
What condition applies if all three must be positive?
Tests: follow-up reasoning
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question