Exercise · Volume 1 · 1.1-6
Exercise 1.1-6
not stated yet in Lean solution written
| Rating | 20 |
|---|---|
| Kind | K3, find a value: compute a number, a set or a closed form from the written solution |
| Section | Section 1.1 of Volume 1. Companion chapter: Algorithms |
The task
Find , the average number of times step E1 runs in Euclid's algorithm when and runs over all positive integers.
The exact wording is in your copy of the book.
Hints
Open one hint at a time. Try the exercise again after each.
Hint 1
The count of E1 depends only on , so only matter.
Hint 2
Run Algorithm E for each of the five values and add the counts.
Solution
Show the solution
Write for the number of runs of step E1 on the input .
- : E1 gives and . Then E1 gives . So .
- : , then with , then with . So .
- : , then with , then with , then with . So .
- : , then with , then with . So .
- : at once. So .
The sum is , so Values give no new counts. Let . If , one run of E1 ends the algorithm, as for . If , the first run gives the pair , and the input gives the same pair after its own first run, so . Each residue occurs once in each block of five consecutive values of , so the average over all is the average over .
Check
The counts for are , and a python3 run of the algorithm gives the same list. For the counts are the same: . The sum is and the average is .
Remarks
The table of for other is in the C1 chapter of Section 1.1. For large , grows like (Section 4.5.3). Exercise 1.1-7 asks the same question with the roles of and changed.
This solution is checked, and a person has not reviewed it yet. The source.
In Lean
not stated yet The exercise is not stated in Lean yet.
The status is computed from the Lean build. The node of the map.
Something is wrong? Report it.