Week 7 notes

Comp 163-002, Spring 2020, MWF, 12:35-1:25, in Mundelein 620

The primary goal of this course is to become familiar with some of the basic mathematical ideas used in programming.


Homework 6

Levin p 188: 5 (proof by induction)

p 323: 6, 8, 17 (one solution is fine, provided your method isn't just trial-and-error)


5.2: Number Theory

An introduction to divisibility and congruence:

if a,b are in N, then a|b, or "a divides b" if ∃k∈N b=ak

b≡c mod a if a|(b-c)

Postage in Investigate!; show 8 cent and 5 cent stamps can make any amount greater than or equal to 28 cents. Proof on p 179

Consequence: for all a,n∈N there is b so: 0≤b<n and b≡a (mod n). So modular arithmetic comes down to Zn = {0,1,...,n-1}

Example 2.5.3: n2 < 2n for n>=5

Warning: Canadians, p 184

gcd theorem

5x≡1 mod 13, 3x≡1 mod 13

Wednesday

straightenup(n) sequence. Plot for n=200, n=600, n=1000

fib(n): why is fib(40) slow?

    nc(0)=nc(1)=1   For n>1, nc(n) = nc(n-1) + nc(n-2) + 1
    prove by induction: nc(n) >= fib(n)

Friday

Solving 17x + 80y = 1

Solving 5x2 ≡ 1 mod 13     and 9x2 ≡ 1 mod 13

        why is the first the same as solving x2 ≡ 8 mod 13?

Fermat's little theorem  ap-1 ≡ 1 (mod p)

    Z13 example    3 has order 3, 5 has order 4


# returns the list a, a*a, a^3, ..., a^n, all mod n
def powerlist(a,n):
    lis = [0]*n
    lis[0] = a % n
    for i in range(1,n):
        lis[i] = a*lis[i-1] % n
    return lis

a*b ≡ 0 mod 15

a|bc, (a,b) = 1 => a|c  

    Proof: Note ∃k ka=bc. Also ∃x,y xa+yb=1. At this point c = cxa + cyb = a(cx + ky), so a|c