back

Mathematics for Programming

How much math should i know? The answer is school level mathematics is enough to start and solve easy to medium level problem solving.

Arithmetic Basics

  • Addition (+), Subtraction (-), Multiplication (*), Division (/): Loops, counters, scaling data; beware integer vs. float division (e.g., 5/2=2 vs 2.5).

  • Modulus (%): Remainders for even/odd (n % 2), cycles, hashing; your “even-mod” is too narrow.

  • Exponents/Powers (^ or **): Growth models, array sizing (e.g., 2^n for bit shifts); absent in your list, causes exponential bugs.

  • Absolute value (|x|): Distances, error metrics; trivial but frequently botched.

Number Theory

  • Divisibility checks (n % k == 0): Factors, grouping; extend to GCD via Euclidean algorithm.

  • Prime/composite numbers: Identify via trial division up to √n.

  • Divisor counting: Sum divisors efficiently (O(√n)); blind loops timeout on large inputs.

  • Primality tests: Basic trial division or Sieve of Eratosthenes for ranges; O(n log log n) beats your implied brute force.

  • Binary/Number systems (base 2, octal, hex): Bitwise ops (& | ^ ~ >> <<), masks, flags.

Logic and Booleans

  • Boolean logic (AND &&, OR ||, NOT !, XOR): Conditions, filters, state machines; no program runs without this.

  • Truth tables: Evaluate expressions.

Probability and Counting

  • Basic probability (events, odds): Simulations, randomness (e.g., random() seeds); define P(A) = favorable/total.

  • Combinations (C(n,k)), Permutations (P(n,k)): Sampling, shuffling; off-by-1 errors kill naive factorials.

Geometry and Coordinates

  • Coordinate systems (Cartesian x,y): Graphics, maps (e.g., distance = √((x2-x1)² + (y2-y1)²)).

  • Basic geometry: Angles (radians for trig funcs), area/perimeter; vectors for direction (dx, dy).

Algorithms Foundations

  • Order of operations (PEMDAS/BODMAS): Expression evaluation; precedence bugs crash code.

  • Min/max, rounding (floor/ceil): Data bounds, normalization.

  • Sums/products (sigma notation basics): Accumulators, stats.

Copyright © 2026 Mahidul Haque. This post is licensed under a CC BY-NC-ND 4.0 license. You may read, learn, and share links to this post for non‑commercial, educational purposes, as long as you give appropriate attribution. You may not copy, reproduce, adapt, distribute, or use this work commercially without explicit permission.