Iteration count of a guarded nested loop
An outer loop runs from to . Only when is even does an inner loop run, executing from to ; on odd the inner loop is skipped entirely. For , how many inner-loop iterations execute in total?
Show hints (2)+
- Only even trigger the inner loop, which then runs times.
- Sum , not .
Answer
Reveal answer →Final answer
30
Create a free account to see the full worked solution and track your progress.
Interview format: Numerical Reasoning Tests, Trading Aptitude Tests