🐻
berkeley
  • #Despair
  • 16A/B
    • Thevenin and Norton Equivalence
    • Resistive Touchscreen
    • Trilateration and Correlation
    • RC Circuits & Transient Analysis
  • 61B
    • Testing
    • References in Java
    • Linked Lists in Java
    • Implementation Inheritance
    • Comparables and Iterators
    • Casting
    • Lists and Sets
    • Asymptotics
    • Trees
    • Hashing
    • PriorityQueue and Heap
    • Graphs, Tree Traversals
    • Tries
    • Sorting
  • Discrete Mathematics
    • Sets + Mathematical Notation
    • Logic and Proofs
    • Induction
    • Cryptography/RSA
    • Modular Arithmetic
    • Discrete Probability
  • Linear Algebra
    • Linear Equations
    • Matrix Algebra
    • Determinants
    • Vector Spaces
    • Eigenvectors and Eigenvalues
    • Projections and Orthogonality
    • SVD/PCA
  • Math 275 — Ordinary Differential Equations
    • Math 275 — Overview
    • Modeling via Differential Equations
    • Linear Systems
  • INTEGBI 35AC
    • Humans Came From Fish
    • Evolution's History
    • Typology
    • The Human Diaspora
  • 170
    • Basics
    • Divide and Conquer
    • Fast Fourier Transform
    • Graphs
    • Greedy
  • 61C
    • Pointers and Memory
    • Floating Point
    • Compliation, Assembly, Linking, Loading
    • RISC-V, Assembly
Powered by GitBook
On this page
  • Primes and Greatest Common Divisors
  • The Fundamental Theorem of Arithmetic
  • The Division Algorithm
  • GCD Algorithms
  • Modular Equivalences
  • Inverses
  • Exponentiation
  • Linear Congruences
  • Chinese Remainder Theorem

Was this helpful?

  1. Discrete Mathematics

Modular Arithmetic

Primes and Greatest Common Divisors

We know that a divides b, written as a|b, if there exists an integer such that b = ak. As for the greatest common divisor, it is the greatest integer d such that d|a and d|b.

The Fundamental Theorem of Arithmetic

This states that every integer greater than 2 can be expressed uniquely as a product of primes. A property of this is that

GCD(a,b)=∑pnmin(αn,βn)GCD(a, b) = \sum p_n^{min(\alpha_n, \beta_n)}GCD(a,b)=∑pnmin(αn​,βn​)​

Where alha and beta are the exponents of the primes.

The Division Algorithm

Let a and b be integers. This means that there are unique integers q and b wuth 0 leq r less than b such that a is equal to qb .+ r.

GCD Algorithms

The Euclidean algorithm: take the GCD of a and b, if b is zero return a, else return teh gcd of b, a mod b,

Bezout's theorem states that there exists coeffiecent integers x and y such that ax + by = GCD (a, b).

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a mod b)

Modular Equivalences

Let a, b be integers and m be a positive integers. if m divides a - b, we say that a is congruent to b modulo m.

Two integers are congruient if they have the same remainders.

Another corollary is that if a is congruent to b mod m, we know that there exists some integer k such that a = km + b.

If a is congruent to b mod m, and c is congruient to d mod m, then a + c = b + d mod m.

Inverses

We say that if ax = 1 mod m, x is an inverse of a mod m, written as a^-1 mod m.

Exponentiation

We want to compute a^n mod m. We can split a^n into its constituents, which is a^k a^k if n is even, and a^k a^k a if it is odd.

Linear Congruences

A linear cogruence is of the fform ay = b (mod m).

If ax is congruent to 1 (mod m) we say that x is the inverse of muodule m.

The inverse can be found iusing the extended euclidean algorithm

Given an equation, ax cong b mod m, check for solutions by seeing if gcd (a, m) = 1

Chinese Remainder Theorem

TODO: Formatting and additional information

PreviousCryptography/RSANextDiscrete Probability

Last updated 3 years ago

Was this helpful?