Modular Arithmetic

Context: FIT1058_MOC Β· remainder operation + congruence Β· an Equivalence Relation partitioning into Β· basis of the Euclidean Algorithm, Modular Inverse and Modular Exponentiation

Quick Revision

  • 🎯 Objective: , βž” remainder operation ⟹ congruence relation ⟹ arithmetic on residue classes.
  • πŸ“¦ Core Components: (operation) βž” (relation) βž” on .
  • ⚑ Key Constraint: negative rounds the quotient down (, so ); division needs a Modular Inverse.

πŸ“ Core

1. The Modulo Operation (Division Algorithm)

  • Division Algorithm βž” unique with , ; .
  • Notation βž” is an infix operation (); zero remainder ⟺ .
  • Negative βž” floor keeps : (largest multiple is ).
  • Programming caveat βž” % agrees for non-negatives; for negatives some languages return β€” % β‰  mathematical mod.

2. Congruence (the Relation)

  • Three definitions βž” .
  • Equivalence structure βž” reflexive/symmetric/transitive (Equivalence Relation) ⟹ partitions into classes .
  • Operation vs relation βž” returns a value; and are true/false; link: .

3. Class Arithmetic on

  • Representative rule βž” , , β€” pick one member each, combine, reduce.
  • Worked micro-example βž” in : , .
  • Division βž” does not transfer in general; needs a Modular Inverse, which exists iff the element is coprime to .
  • Everyday instances βž” weekdays (mod 7), clocks (mod 24), parity toggle (mod 2), last digit (mod 10).

When It Flips: for fixed the pair is unique, making well-defined; replacing repeated subtraction with one is exactly the speed-up from naΓ―ve gcd to the Euclidean Algorithm.

⚠️ Common Mistakes

  • πŸ’‘ , not βž” the floor convention forces ; a language’s % might return but mathematical mod never does.
  • πŸ’‘ equation β‰  congruence βž” ” in ” is an equation (the only value there); "" is a congruence (also ); but ” in ” is wrong ().

🧠 Active Recall