
| gcd(124,217)=31 | ||||
| n | a | b | remainder, r | |
| 1 | 217= | 124·1+ | 93 | Divide the larger number, a, by the smaller, b, and add the remainder, r1. |
| 2 | 124= | 93·1+ | 31 | The previous b, 124, becomes the new a. Divide a by b and add the remainder, r2. |
| 3 | 93= | 31·3+ | 0 | The new a is the old b, 93, and the new b is the old reminder, r2. Divide a by b and add the remainder, r3. The remainder is 0, so the gcd is the previous non-zero remainder (r2). |
| gcd(97,42)=1 | ||||
| n | a | b | remainder, r | |
| 1 | 97= | 42·2+ | 13 | We divide a by b and add the remainder. |
| 2 | 42= | 13·3+ | 3 | The previous b becomes the new a, and the previous remainder, r1, becomes the new b, and we divide as before, adding the new remainder, r2. |
| 3 | 13= | 3·4+ | 1 | We continue in the pattern established. |
| 4 | 3= | 1·3+ | 0 | The remainder is now 0, so the previous non-zero remainder, r3, is the gcd. In this case, it is 1, so the numbers are relatively prime. |
| gcd(987,960)=3 | |||||||
| Least Positive Remainder | Least Absolute Remainder | ||||||
| n | a | b | r | a | b | r | |
| 1 | 987= | 960·1+ | 27 | 987= | 960·1+ | 27 | |
| 2 | 960= | 27·35+ | 15 | 960= | 27·35+ | 15 | |
| 3 | 27= | 15·1+ | 12 | 27= | 15·2- | 3 | |
| 4 | 15= | 12·1+ | 3 | 15= | 3·5+ | 0 | |
| 5 | 12= | 3·4+ | 0 | ||||
[1.1]
[1.1, repeated]