Skip to content

Sequences and Series

1. Why It Matters

In programming contests, sequences show up everywhere:

  • Efficiency checks → how fast values grow, or if they stop at some point.
  • Spotting patterns → arrays with constant steps (AP), doubling (GP), or recurrences.
  • While coding → loops that generate terms, prefix sums, or noticing when numbers start repeating.

It’s not about memorizing math formulas — it’s about seeing the pattern and coding it fast.


2. The Basics You’ll Actually Use

  • Arithmetic progression (AP) → adds the same number each time.

    • Formula:

    • Example: with step .

    • Why useful? Easy to generate in a loop, prefix sums are predictable.

  • Geometric progression (GP) → multiplies by the same number each time.

    • Formula:

    • Example: with ratio .

    • Why useful? Models exponential growth (like binary splitting, doubling strategies).

  • Arithmetico-Geometric progression (AGP) → mix of both.

    • Formula:

    • Example: .

    • Why useful? Shows up when you combine addition + multiplication (like recurrences with both).


3. Handy Properties

  • Monotonic (always increasing or decreasing) → great for binary search or two-pointer tricks.
  • Bounded (stays inside a limit) → helps know if loops end or numbers won’t overflow.
  • Periodic (values repeat) → common with modulo operations, hashing, and state machines.

4. Resources to Explore