Hiring process8 levels
  1. 1 IQ Test
  2. 2 Additional Online Test (If Required)
  3. 3 Office Interview with Hiring Manager
  4. 4 Unpaid Test Task (Motivation Check)
  5. 5 Paid Test Task and Follow-Up Interview
  6. 6 Iterative Paid Test Tasks
  7. 7 Office Verification
  8. 8 Final Interview with the Founder

Problems > Sum 1 to N > Editorial

Sum 1 to N — Solution & Editorial

Back to the Problem

Use the closed form N(N+1)/2 — a loop also passes but the formula is O(1).

Complexity: O(1)

Watch out: The answer reaches ~5×1017 — use 64-bit arithmetic.