MTH 225 Lecture-Module #11:
More Regarding Integers: Divisors


for a pair of integers a and b,
we write "a|b" if a times something equals b,
i.e. if b is a multiple of a
i.e. if one can find an integer  c  such that   a* := b
e.g. 2|18 is true because   2* := 18
e.g. 3|18 is true because   3* := 18
e.g. 4|18 is not true
    which we would write as "4∤18" or maybe "4∤18"
    but Web-browsers may not render well  (:-\

for nonnegative numbers a, b,
when a|b is true  we say "a is a  of b"
e.g. we say 2 is a divisor of 18
e.g. we say 3 is a divisor of 18
e.g. we say 4 is not a divisor of 18

more different (;-) examples:
e.g. ? 18|18? 
e.g. ? 1|18? 
e.g. ? 0|18? 
e.g. ? 18|0? 
e.g. ? 1|0? 
e.g. ? 0|0? 
e.g. ? for any a, a|0? 

again using the term "divisor",
we would say that 1 and 18 are (more) divisors of 18,
0 is not a divisor of 18,
any value a is a divisor of 0

people usually pronounce "a|b" as "a divides b"
which somewhat reflects the situation
but may be confusing/misleading
e.g. saying "2 divides 18" and "3 divides 18" does reflect that "18÷2" and "18÷3" are 'even' divisions, yielding an integer each time,
but:
  • reading "a|b" as "a divides b" might make one think of doing "a÷b"
    though "a|b" involves "b÷a", not "a÷b"
    e.g. 2|18 involves "18÷2" not "2÷18"
  • reading "0|0" as "0 divides 0" might make one think one must do "0÷0"?!?
    though that's undefined;
    it's not necessary to do "0÷0",
    it suffices that 0 times something equals 0

    nonetheless, reading "a|b" as "a divides b" is standard
    and there are some valid points involving it:
  • a|b is true if dividing b by a yields a remainder of 
  • that's true further if   b mod a := 

    anyway, continuing with examples:
    e.g. what are all the divisors of 18? 
    e.g. what are all the divisors of 20? 
    e.g. what are all the divisors of 21? 
    e.g. what are all the divisors of 25? 
    e.g. what are all the divisors of 28? 
    e.g. what are all the divisors of 29? 
    e.g. what are all the divisors of 30? 
    e.g. what are all the divisors of 32? 
    e.g. what are all the divisors of 5? 
    e.g. what are all the divisors of 4? 
    e.g. what are all the divisors of 3? 
    e.g. what are all the divisors of 2? 
    e.g. what are all the divisors of 1? 
    e.g. what are all the divisors of 0? 

    a question that arises sometimes is:
    what are the common divisors of two numbers?
    e.g. for 32 and 20, common divisors are: 
    e.g. for 28 and 21, common divisors are: 
    e.g. for 25 and 18, common divisors are: 
    e.g. for 30 and 3, common divisors are: 
    e.g. for 5 and 5, common divisors are: 
    e.g. for 5 and 4, common divisors are: 
    e.g. for 5 and 3, common divisors are: 
    e.g. for 5 and 2, common divisors are: 
    e.g. for 5 and 1, common divisors are: 

    having just 1 as the only divisor in common with every other integer
    (other than multiples of itself)
    is the hallmark of a prime such as 5, 29, 3, 2, etc.

    but as with 25 and 18, two numbers that aren't prime can have just 1 as their only common divisor
        when they have no 'real' (nontrivial) common divisor 2 or greater
    then in this case (and also when one of the numbers really is prime),
    the two numbers are called 
    a.k.a. "prime to one another" a.k.a. "coprime"
    e.g. 18 and 25 are relatively prime
    e.g. 5 and 20 are  relatively prime
    e.g. 3 and 4 are relatively prime
    e.g. 1 and 4 are relatively prime
    e.g. 5 is relatively prime to each of 
    application of relative primality: conditions for cryptography (next lecture module)

    another way to say that two numbers have just 1 as their only common divisor
    is to say that their greatest common divisor is 
    notation "gcd(a,b)" is used to denote the greatest common divisor of a and b
    (a.k.a. "greatest common factor" gcf(a,b) )
    e.g. gcd(20,32) := 
    e.g. gcd(21,28) := 
    e.g. gcd(18,25) := 
    e.g. gcd(3,30) := 
    e.g. gcd(5,5) := 
    e.g. gcd(3,4) := 
    e.g. gcd(2,4) := 
    e.g. gcd(1,4) := 
    thus again, numbers relatively prime to 4 include 

    applications of gcd():
    * reducing fractions to lowest terms
    * inverses for cryptography (next lecture module)

    just the count of how many numbers smaller than a number n that are relatively prime to it
    has intriguing properties
    this count is denoted "φ(n)" and is called "Euler's totient function"
        or sometimes just "Euler's phi() function"
    e.g. φ(4) := 
    e.g. φ(5) := 
    e.g. φ(9) := 


    to start seeing an intriguing property of φ(n), consider:
    3φ(4) mod 4   :=   32 mod 4   :=    mod 4   :=   
    and:
    2φ(5) mod 5   :=   24 mod 5   :=    mod 5   :=   
    3φ(5) mod 5   :=   34 mod 5   :=    mod 5   :=   
    4φ(5) mod 5   :=   44 mod 5   :=    mod 5   :=   
    and:
    2φ(9) mod 9   :=   26 mod 9   :=    mod 9   :=   
    4φ(9) mod 9   :=   46 mod 9   :=    mod 9   :=   
    5φ(9) mod 9   :=   56 mod 9   :=    mod 9   :=   
    ·
    ·
    ·

    an application of φ() is (guess what?) cryptography
    as presented in next lecture module


    but first, can calculate gcd(a,b) without listing divisors of a,b?
    yes, considering the following:
    as when you were completely/thoroughly factoring numbers,
    every positive integer n ≥ 1 can be represented as a product of the primes
            n =  e2e3e5e7 * ...
    (the Fundamental Theorem of Arithmetic says this)
    e.g. 90 = 2 * 3 * 5 * 7 * 11 * 13 * 17 * ...
    e.g. 75 = 2 * 3 * 5 * 7 * 11 * 13 * 17 * ...
    e.g. 210 = 2 * 3 * 5 * 7 * 11 * ...
    e.g. 1001 = 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * ...
    e.g. 1 = 2 * 3 * 5 * 7 * 11 * 13 * ...
    e.g. 3 = 2 * 3 * 5 * 7 * 11 * 13 * ...

    then one way to obtain gcd(a,b) is as follows:
    if prime factorization of a is  2e2 * 3e3 * 5e5 * 7e7 * ...
    and prime factorization of b is  2f2 * 3f3 * 5f5 * 7f7 * ...
    then  gcd(a,b) := 2min(e2,f2) * 3min(e3,f3) * 5min(e5,f5) * ...
    e.g. for gcd(72,54):
    54 = 2 * 3 * 5 * 7 * 11 * ...
    72 = 2 * 3 * 5 * 7 * 11 * ...
    so gcd(54,72) should be  2 * 3 * 5 * 7 * 11 * ...
    which is 
    check:
    does 18|54? 
    does 18|72? 
    does anything larger than 18 evenly divide both 72 and 54? 

    e.g. gcd(23 * 310 * 50 * 70 * 111 * 130 * 170 * 190 * ... ,
                        22 * 38 * 54 * 70 * 110 * 135 * 170 * 190 * ...
                        )
                    := 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * ...

    considering this scheme, revisit "relative primality", which is true for a pair of numbers a,b if gcd(a,b) := 1
    well, 1 == 2 * 3 * 5 * 7 * 11 * 13 * ...
    so clearly a,b relatively prime if they share no common prime factors
    e.g.:
        18 == 2 * 3 * 5 * 7 * 11 * 13 * ...
        and
        25 == 2 * 3 * 5 * 7 * 11 * 13 * ...
        so
        gcd(18,25) := 2 * 3 * 5 * 7 * 11 * 13 * ...
            := 
        thus (as indicated above) 25 and 18 are relatively prime


    but what about e.g. gcd(0,9)? what is the prime factorization of 0?!?
    don't worry: the scheme using prime factorizations is just one way to calculate gcd(), not the only way
    in this case, review the real definition of gcd() above:
    gcd(0,9) supposed to be the largest integer d such that d|0 and d|9

    well, first what are the divisors of 9? 
    and what are the divisors of 0? 
    and what is the largest number in common between those two lists? 
    then gcd(0,9) := 
    similarly gcd(0,5) := 
    and then clearly for any natural number a,   gcd(0,a) := 


    it's not as significant/useful as gcd(), but
    "lcm(a,b)", the least common multiple of positive integers a and b,
    is the smallest positive integer c
    that is a multiple of a and a multiple of b.
    e.g. lcm(20,28) := 
    e.g. lcm(20,100) := 
    e.g. lcm(23,23) := 
    one way to get lcm(a,b) is as follows:
    if prime factorization of a is  2e2 * 3e3 * 5e5 * 7e7 * ...
    and prime factorization of b is  2f2 * 3f3 * 5f5 * 7f7 * ...
    then  lcm(a,b) :=  2max(e2,f2) * 3max(e3,f3) * 5max(e5,f5) * ...
    e.g.:
      60  =           2 * 3 * 5 * 7 * 11 * 13 * ...
      and 350  =      2 * 3 * 5 * 7 * 11 * 13 * ...
      so
      lcm(60,350) :=  2 * 3 * 5 * 7 * 11 * 13 * ...
                  :=  
    
    contrast checking multiples of say 350 until also
    have a multiple of 60:  0? 350? 700? 1050?? 1400? 1750? 2100? 
    another e.g.:
      54  =         2 * 3 * 5 * 7 * ...
      and 72  =     2 * 3 * 5 * 7 * ...
      so
      lcm(54,72) := 2 * 3 * 5 * 7 * ...
                 := 
    

    an observation:
    for any positive integers a and b,
    a * b  ==  gcd(a,b) * lcm(a,b)
    e.g. 60*350 =?= gcd(60,350)*lcm(60,350) ?
             
    e.g. 54*72 =?= gcd(54,72) * lcm(54,72) ?
             
             



    Euclidean algorithm:
    for calculating gcd(a,b)
        efficient!
    based on the following two observations
    for obtaining gcd(x,y) from simpler situation

    [1] gcd(0,y) :=  for any natural number y

    [2]  gcd(x,y) == gcd(y mod x, x)    if  x ≠ 0
    e.g.  gcd(16,56) := gcd(56 mod 16, 16) := gcd(, 16) := ?
        check: does 8|16 and does 8|56
        and is there no larger common divisor?
    e.g.  gcd(50,65) := gcd() := gcd(, 50)
        applying rule again:
        gcd(15,50) := gcd() := gcd(, 15) := 5
        check: does 5|50 and does 5|65
        and is there no larger common divisor?
    justification of this observation "gcd(a,b) := gcd(b mod a, a)":
    review definitions of "mod" and "gcd()" and "|":
    b mod a  is value r satisfying 
    gcd(b mod a, a)  i.e.  gcd(,a)  is value g satisfying  g|r  and  g|a
        and g is largest value d such that d|r and d|a
        i.e. if d|r and d|a, then  g ≥ d
    g|r  meand  for some k2
    g|a  means  for some k1
    well, let's do some substitutions into "b = a*q + r":
    b = *q +  = 
    thus 
    b = g*k3 for some k3, namely k3 = 
    hence  (by definition of "|")
    and g|a was indicated a few lines earlier
    thus g satisfies two of the three conditions for being gcd(a,b):
        (i)  g|a, and (ii)  g|b
    and does g satisfy the third condition,
    i.e. is g the largest value d such that d|a and d|b?
    i.e. if d|a and d|b, is  g ≥ d?
    well, suppose h is a value such that  h|a  and  h|b
    then  a = h*k4  and  b = h*k5  for some k4,k5   by definition of "|"
    remember  b = a*q + r    so  r = b - a*q
    substituting,  r =  - *q = h*(k5 - k4*q)
    then  r = h*k6  for some k6, namely  k6 = 
    then  (by definition of "|")
    and  h|a  was indicated a few lines earlier
    thus h is a value d such that  d|a  and  d|r
    but then applying property given in initial specification of g,   g ≥ h
    thus g also satisfies third (and final) condition for being gcd(a,b)
    and g was  gcd(b mod a, a)
    thus  gcd(a,b) = gcd(b mod a, a)


    how do those two observations help encode procedure to determine gcd(x,y)?
    well, rem. observation [1] is that  gcd(0,y) := y
    so  gcd(x,y)  can clearly be determined when  x is 
    then to compute  gcd(x,y), what's done is that observation [2] is used to repeatedly reduce the given values of x and y to smaller values
    to reach the case of x being 0 at which point observation [1] can be applied to obtain result
    rem. observation [2] is that  gcd(x,y) == gcd(x mod y, x)
    this fact is used to reduce x,y to smaller values by reassigning x to  y mod xold  and reassigning y to xold
    the new value y mod xold  is smaller than the old value xold
    according to the definition of "mod"
        (y mod xold    returns a remainder
        which is one of the values {0,1,2,...,(xold-2),(xold-1)})
    here's Java encoding of this algorithm:

    e.g. trace invocation of  gcd(16,56):
                                                    x       y
    int gcd(int x, int y) {                             
        while ( x != 0   ) {                   x       y
            int  x_next = y % x,  y_next = x;       x       y
                                         x       y
                                            x       y
            x = x_next;                                   y
            y = y_next;                             x      
            }                                       x       y
        while ( x != 0   ) {                   x       y
            int  x_next = y % x,  y_next = x;       x       y
                                           x       y
                                            x       y
            x = x_next;                                   y
            y = y_next;                             x      
            }                                       x       y
        while ( x != 0   )                    x       y
        return  y ;                               x       y
        }
    
    e.g. trace invocation of  gcd(50,65):
                                                    x       y
    int gcd(int x, int y) {                             
        while ( x != 0   ) {                   x       y
            int  x_next = y % x,  y_next = x;       x       y
                                         x       y
                                            x       y
            x = x_next;                                  y
            y = y_next;                             x      
            }                                       x       y
        while ( x != 0   ) {                   x       y
            int  x_next = y % x,  y_next = x;       x       y
                                         x       y
                                            x       y
            x = x_next;                                   y
            y = y_next;                             x      
            }                                       x       y
        while ( x != 0   ) {                   x       y
            int  x_next = y % x,  y_next = x;       x       y
                                           x       y
                                            x       y
            x = x_next;                                   y
            y = y_next;                             x      
            }                                       x       y
        while ( x != 0   )                    x       y
        return  y ;                               x       y
        }
    


    (Copyright © 2009 by Hugh McGuire   — for thoughts about this, see   http://www.cis.gvsu.edu/~mcguire/teaching/copyright_thoughts.html .)