ΘρϵηΠατπ

euclidean algorithm
Let m,n1 such that m>;n, if m % n>;0, then gcd(m,n)=gcd(n,m % n). Otherwise if m % n=0, then n|m and gcd(m,n)=n

If m % n=0, then m=(m//n)n, therefore gcd(m,n)=gcd((m//n)n,n)=n, so now assume that m % n>;0

Recall that m=(m//n)n+m % n, therefore m(m//n)n=m % n, so that if d divides both m,n, then it must divide m % n (and clearly n), and by the original equation if d is a divisor of both n,m % n then d divides m (and clearly n).

The above paragraph shows that a number is a divisor of m,n if and only if it is a divisor of n,m % n, which shows that their set of divisors are equal and thus gcd(m,n)=gcd(n,m % n)

bounded sum implies one less then half
Suppose that x,y,b1 and x<;y with x+yb, then x<;b2
Suppose for the sake of contradiction that xb2, then we know that y>;xb2 so therefore x+y>b2+b2=b, so we have x+y>;b which is a contradiction so that x<;b2.
euclidean algorithm has exponentially decreasing remainders
Let a,b1 with ab be two integers, and suppose we will preform the euclidean algorithm on them to compute gcd(m,n), supposing that rk represents the remainder after k (where k1) steps into the euclidean algorithm, then r2n<b2n

For the base case, suppose that n=1, so we'd like to prove that r2<b2. Firstly we know that a=bq0+r0 with 0r0<b, then applying the next iteration we have b=r0q1+r1 with 0r1<r0 and one more time, we get r0=r1q2+r2 with 0r2<r1, this shows us that b=(r1q2+r2)q1+r1.

Since ab, b>r0 and r0>r1, then q01, q11 and q21, therefore b=(r1q2+r2)q1+r1(r11+r2)1+r1r1+r2 therefore r2<;b2 which concludes the base case

Now let k1 assuming that r2kb2k, we want to prove that r2(k+1)=b2k+1, noting that 2(k+1)=2k+2.

To start let's say we have an intance of the euclidean algorithm that lasts for at least 2k+2 iterations, therefore we know that r2kb2k by our induction hypothesis, additionally at the 2k-th iteration we would have an equation of the form r2k=r2k+1(q2k+2)+r2k+2, since we know that r2k+1>;r2k+2, then q2k+21, which then shows that r2k=r2k+1(q2k+2)+r2k+2r2k+1+r2k+1, and since b2k>r2k , then we know that r2k+2<12b2k=b2k+1 which is what we needed to show

upper bound on euclidean algorithm iterations
The euclidean algorithm terminates in at most 2log2(b) iterations
The euclidean algorithm terminates in k iterations if and only if rk=0, we know that for all n1 that r2n<b2n, therefore when n=log2(b), then we have r2log2(b)<b2log2(b)=bb=1, but if r2log2(b)<1, then since the remainders are always elements of 0, then we know that r2log2(b)=0, thus we've shown after 2log2(b) iterations the algorithm must terminate