t ← a b ← a a ← t t ← b c ← b b ← t t ← c d ← c c ← t
t ← a (save a state) a ← b, b ← c, c ← d, d ← t
In step 3, we know that m ← n and n ← r, so it is sufficient
to prove that r < n. we have m = an + r
where a is the largest number
that satisfies the equation. For sake of contradiction, suppose that
r ≥ n, this implies
r = n + b
where b ≥ 0 ⟹ m = an + n + b
⟹ m = (a + 1)n + b
which is a contradiction, we assumed that a is the largest number that
satisies the equation of that form.
TODO wrong, it requires 3 is zero checks and 3 remainder checks, see answerbook The [[the_euclidean_algorithm___11_06_2022__090230167|Steps]] is as follows.
1.6099/2166 = 2 r 1767 (6099 - 4332) .. 1767, 399 .. 399, 171 .. 171, 57 .. 57
The average number of times the step E1 will be computed
with n ← 5. TODO plug in m = 1, 2, 3, 4, 5 and then find
average.
The number of times an algorithm executes E1 is well
defined as we know that E1 is deterministic and finite. We
then divide by n and take a
limit for the set of ℝ. $\lim_{n \to \infty} \frac{\text{ The number of
times E1 is executed }}{n}$ This in unambiguous, in other words
well defined.
With step E0, Um and Tn are the
same.
Without it there would be a step involving the switch of the two. Um = Tn + 1 where m < n Um = Tn otherwise.
In all but a finite number of cases, n > m. In this caase,
the first iteration of Algorithm E merely exchanges these
numbers; so Um = Tm + 1
TODO We are given.
f((m, n)) = (m, n, 0, 1); f((n)) = (n);
f((m, n, r, 1)) = (m, min (m, n), |m − n|, 2);
f((m, n, r, 2)) = (n) if r = 0, (m, n, r, 3) otherwise ;
f((m, n, p, 3)) = (n, p, p, 1)
Let A = {a, b, c}, N = 5. The algorithm will terminate with the string agcd(m, n)
| j | θj | ϕj | bj | aj | Comment |
|---|---|---|---|---|---|
| 0 | ab | (empty) | 1 | 2 | Remove one a and one b, or go to 2 |
| 1 | (empty) | c | 0 | 0 | Add c at the extreme left, go back to 0 |
| 2 | a | b | 2 | 3 | Change all a’s to b’s |
| 3 | c | a | 4 | 4 | Change all c’s to a’s |
| 4 | b | b | 0 | 5 | If b’s remain, repeat |