CSEC3616Cybersecurity Engineering

    Divisibility and the greatest common divisor

    Divisibility notation and properties, the division algorithm, and the Euclidean algorithm for computing a greatest common divisor.

    • State the four basic properties of divisibility, including transitivity and the linear-combination property.
    • Apply the division algorithm to write any integer as a=qn+r with 0<=r<n.
    • Compute gcd(a, b) by hand using the Euclidean algorithm.

    12 min readJump to the quiz ↓

    Divisibility means no remainder, and it survives any combination

    Every later idea in this module rests on one question: does one number split evenly into another? RSA key generation depends on it directly. An encryption exponent ee only has a working decryption partner dd because gcd⁡(e,φ(n))=1\gcd(e, \varphi(n)) = 1. Modular inverses and the extended Euclidean algorithm on the next page start from the same machinery.

    A non-zero integer bb divides aa if a=mba = mb for some integer mm, so dividing aa by bb leaves no remainder. This is written b∣ab \mid a, and bb is a divisor of aa. For example, 13∣18213 \mid 182 because 182=14×13182 = 14 \times 13, and 17∣28917 \mid 289 because 289=17×17289 = 17 \times 17.

    Four properties follow directly from the definition:

    • If a∣1a \mid 1, then a=±1a = \pm 1.
    • If a∣ba \mid b and b∣ab \mid a, then a=±ba = \pm b.
    • Any b≠0b \neq 0 divides 00.
    • Transitivity: if a∣ba \mid b and b∣cb \mid c, then a∣ca \mid c.

    Transitivity holds because a∣ba \mid b and b∣cb \mid c mean b=amb = am and c=bnc = bn for some integers m,nm, n. Substituting the first into the second gives c=amnc = amn, so a∣ca \mid c. The lecture gives two instances: 3∣93 \mid 9 and 9∣279 \mid 27 give 3∣273 \mid 27; 11∣6611 \mid 66 and 66∣19866 \mid 198 give 11∣19811 \mid 198.

    A stronger property extends this to combinations. If b∣gb \mid g and b∣hb \mid h, then bb divides mg+nhmg + nh for any integers mm and nn, not just g+hg + h or g−hg - h. This is the linear combination property. The lecture’s example: 11∣6611 \mid 66 and 11∣7711 \mid 77, so 1111 divides m⋅66+n⋅77m \cdot 66 + n \cdot 77 for any m,nm, n. Writing 66=11k66 = 11k and 77=11l77 = 11l, m⋅66+n⋅77=m⋅11k+n⋅11l=11(mk+nl),m \cdot 66 + n \cdot 77 = m \cdot 11k + n \cdot 11l = 11(mk + nl), which is a multiple of 1111 whatever mm and nn are.

    Recall

    Why does 11 | 66 and 11 | 77 guarantee 11 divides m·66 + n·77 for every integer m and n?

    Because 66=11k66 = 11k and 77=11l77 = 11l for some integers k,lk, l. Substituting, m⋅66+n⋅77=11(mk+nl)m \cdot 66 + n \cdot 77 = 11(mk + nl), which is 1111 times an integer, so 1111 divides it whatever mm and nn are.

    The division algorithm gives a unique quotient and a non-negative remainder

    The division algorithm formalises ordinary long division. For a positive integer nn and a non-negative integer aa, a=qn+r,0≤r<n,q=⌊an⌋.a = qn + r, \quad 0 \le r < n, \quad q = \left\lfloor \frac{a}{n} \right\rfloor. qq is the quotient, rr is the remainder, and ⌊⋅⌋\lfloor \cdot \rfloor is the floor function: the greatest integer no larger than the argument. The remainder is always non-negative and strictly less than nn. That constraint is what makes qq and rr unique for a given aa and nn.

    Formula

    Division algorithm

    a=qn+r,0≤r<n,q=⌊an⌋a = qn + r, \quad 0 \le r < n, \quad q = \left\lfloor \frac{a}{n} \right\rfloor
    aa
    the dividend
    nn
    the divisor (positive)
    qq
    the quotient
    rr
    the remainder, 0 <= r < n

    Pitfall

    q=⌊a/n⌋q = \lfloor a/n \rfloor, not a/na/n rounded or truncated toward zero. For non-negative aa and positive nn these agree, but do not carry the habit of “round toward zero” into modular arithmetic on the next page, where negative dividends make the two rules disagree.

    The Euclidean algorithm finds the gcd by repeated division

    The greatest common divisor of aa and bb, gcd⁡(a,b)\gcd(a, b), is the largest integer that divides both: gcd⁡(a,b)=max⁡{k:k∣a and k∣b}\gcd(a, b) = \max\{k : k \mid a \text{ and } k \mid b\}. The definition requires a positive result, so gcd⁡(a,b)=gcd⁡(∣a∣,∣b∣)\gcd(a, b) = \gcd(|a|, |b|). Every integer divides 00, so gcd⁡(a,0)=∣a∣\gcd(a, 0) = |a|, and gcd⁡(0,0)\gcd(0, 0) is defined to be 00.

    Two integers are relatively prime if their only common positive divisor is 11, equivalently gcd⁡(a,b)=1\gcd(a, b) = 1.

    Exam detail

    Neither number has to be prime itself. 88 and 1515 are relatively prime: the divisors of 88 are 1,2,4,81, 2, 4, 8, the divisors of 1515 are 1,3,5,151, 3, 5, 15, and 11 is the only entry on both lists.

    The Euclidean algorithm finds gcd⁡(a,b)\gcd(a, b) by repeated application of the division algorithm: replace (a,b)(a, b) with (b,a mod b)(b, a \bmod b) and repeat until the remainder is 00. The last non-zero remainder is the gcd. Each remainder is smaller than the last, so the algorithm always terminates.

    Try it — worked example

    Use the Euclidean algorithm to find gcd(710, 310).

    Show answer and steps

    Answergcd(710, 310) = 10

    The lecture names this exact example, but the figure showing its working did not survive extraction from the source PDF. The steps below apply the division algorithm repeatedly, exactly as defined above.

    1. 710=2×310+90710 = 2 \times 310 + 90: divide 710 by 310, quotient 2, remainder 90.
    2. 310=3×90+40310 = 3 \times 90 + 40: repeat on (310, 90).
    3. 90=2×40+1090 = 2 \times 40 + 10: repeat on (90, 40).
    4. 40=4×10+040 = 4 \times 10 + 0: the remainder is 0, so the algorithm stops.
    5. The last non-zero remainder was 1010, so gcd⁡(710,310)=10\gcd(710, 310) = 10.

    Check yourself