CodeHive
open main menu
Roadmap hero image
Part of series: Maths Roadmap for CP

🧮 6-Week Roadmap to Math for Coding & Problem Solving

/ 3 min read

Hey there 👋

👋 Introduction

If you’ve been grinding LeetCode, Codeforces, or any kind of competitive programming, you probably noticed something sneaky:
👉 a lot of problems boil down to math.

Whether it’s GCD/LCM, modular arithmetic, prime numbers, or probability — math concepts show up everywhere. And the best part? You don’t need to be a “math genius” to use them. You just need the right toolkit and some practice.

That’s what this 6-week study plan is about. We’ll go step by step, learn the essentials, code them up in C++, and then apply them on real problems.

Each week is broken into daily blogs (Day 1, Day 2, …), so it’s bite-sized and fun. By the end of 6 weeks, you’ll feel way more confident when math sneaks into your coding interviews or contests.


🗓️ The Plan

Here’s what we’ll cover week by week:

Week 1: Number Theory Basics

  • GCD & LCM (the unsung heroes of many problems)
  • Modular arithmetic (mod, inverse, fast power)
  • Prime numbers, factorization, sieve of Eratosthenes
  • Applications in arrays, divisibility, and cycles

Week 2: Modular Math & Exponentiation

  • Modular exponentiation (fast power)
  • Modular inverses & Fermat’s little theorem
  • Extended Euclidean algorithm
  • Using modular math in coding challenges

Week 3: Combinatorics & Counting

  • Factorials & binomial coefficients
  • nCr and nPr (with modular math)
  • Inclusion-exclusion principle
  • Pigeonhole principle
  • Common LeetCode/Codeforces problems on counting

Week 4: Probability & Expectations

  • Probability basics for coding
  • Expected values
  • Randomized problems (hashing, rolling dice, etc.)
  • Classic problems from contests

Week 5: Advanced Number Theory Tools

  • Chinese Remainder Theorem
  • Euler’s Totient Function
  • Fast primality checks
  • Linear Diophantine equations

Week 6: Geometry & Miscellaneous Math Tricks

  • Basic computational geometry (lines, distances, orientation)
  • Vectors & dot product
  • Coordinate geometry in coding problems
  • Misc math tricks you see in CP (floor/ceil, logarithms, etc.)
Week 1 🔢 Number Theory BasicsWeek 2 ✨ Modular Math & PowersWeek 3 🧮 Combinatorics
Day 1: GCD & LCMDay 1: Fast exponentiationDay 1: nCr basics
Day 2: Euclidean AlgorithmDay 2: Modular multiplicationDay 2: Pascal’s Triangle
Day 3: LCM applicationsDay 3: Modular inverseDay 3: nCr mod prime
Day 4: Sieve of EratosthenesDay 4: Fermat & EulerDay 4: Inclusion-Exclusion
Day 5: Prime factorizationDay 5: Matrix exponentiationDay 5: Counting problems

Week 4 🎲 Probability & ExpectationsWeek 5 🧩 Advanced Number TheoryWeek 6 📐 Geometry & Misc
Day 1: Basic probabilityDay 1: Chinese Remainder TheoremDay 1: Dot product
Day 2: Expected valueDay 2: Euler’s TotientDay 2: Cross product
Day 3: Probability in countingDay 3: Extended EuclideanDay 3: Convex hull
Day 4: Randomized algorithmsDay 4: Diophantine equationsDay 4: Bit manipulation tricks
Day 5: Mixed problemsDay 5: Primality testingDay 5: Contest problems

🔑 Legend:

  • 🔢 Number Theory
  • ✨ Modular Arithmetic
  • 🧮 Combinatorics
  • 🎲 Probability
  • 🧩 Advanced Number Theory
  • 📐 Geometry & Misc

💡 How We’ll Learn

  • Concept First – A casual explanation with examples & intuition.
  • Visual/Mindmap – Sometimes an ASCII diagram or simple visualization.
  • Code in C++ – Short snippets to see the concept in action.
  • Practice Problems – Links to LeetCode, Codeforces, or AtCoder.
  • External References – Best articles/videos if you want to go deeper.

🎯 End Goal

By the end of 6 weeks, you’ll:

  • Know the core math concepts that show up in 90% of coding problems.
  • Have reusable C++ templates/snippets for math-heavy problems.
  • Feel confident applying math without overthinking it.

📌 Each daily blog will be linked here once it’s published. So think of this as the master roadmap.


Ready? Let’s dive in → Week 1, Day 1: GCD & LCM