Title: Homework
1Homework 5, Problem 1 Work Stallings 4.9 a
and b. Part a (15 points). Determine GCD (
24140, 16762). Solution 24140/16762 Q of 1,
R of 7378 16762/7378 Q of 2, R of
2006 7378/2006 Q of 3, R of 1360 2006/1360 Q
of 1, R of 646 1360/646 Q of 2, R of 68 646/68
Q of 9, R of 34 68/34 Q of 2, R of 0 34/0 so
GCD 34
2Homework 5, Problem 1b Part b. Determine GCD
( 4655, 12075). Solution 12075/4655 Q of 2,
R of 2765 4655/2765 Q of 1, R of 1890 2765/1890
Q of 1, R of 875 1890/875 Q of 2, R of
140 875/140 Q of 6, R of 35 140/35 Q of 4, R
of 0 35/0 so GCD 35
3Homework 5, Problem 2 Work Stallings problem
4.11 a and b. Part a. Find GCD (2152, 764) using
both Euclids and Steins algorithm. Solution
Euclid GCD (2152, 764) 2152/764 Q of 2, R of
624 764/624 Q of 1, R of 140 624/140 Q of 4,
R of 64 140/64 Q of 2, R of 12 64/12 Q of 5,
R of 4 12/4 Q of 3, R of 0 4/0 so GCD is 4
4- Homework 5, Problem 2a Stein
- A B C
- 1 2152 764 1 (initialized state)
- 2 1076 382 2
- 3 538 191 4
- 4 269 191 4
- 5 78 191 4
- 6 39 191 4
- 7 152 39 4
- 8 76 39 4
- 9 38 39 4
- 10 19 39 4
- 11 20 19 4
- 12 10 19 4
- 13 5 19 4
- 14 14 5 4
- 15 7 5 4
- 16 2 5 4
- 17 1 5 4
5Homework 5, Problem 2b What is the apparent
advantage of Stein over Euclids? Stein uses
simpler arithmetic Euclid requires integer
(long) division at each step. Stein requires
only division by 2 and determining magnitude and
minimums. Stein takes more steps Which is
fastest depends on relative performance of the
arithmetic vs shift/magnitude operations.
6Homework 5, Problem 3 Work Stallings 4.13 a,
b, and c using your program. Part a. 1234 mod
4321. Solution 3239 Part b. 24104 mod
40902. Solution GCD (40902, 24104) 34 so there
is no multiplicative inverse. Part c. 550 mod
1769 Solution 550