The GCD of given numbers is 2.
Step 1 :
Divide by and get the remainder
The remainder is positive (), so we will continue with division.
Step 2 :
Divide by and get the remainder
The remainder is still positive (), so we will continue with division.
Step 3 :
Divide by and get the remainder
The remainder is still positive (), so we will continue with division.
Step 4 :
Divide by and get the remainder
The remainder is zero => GCD is the last divisor .
We can summarize an algorithm into a following table.
58 | : | 40 | = | 1 | remainder ( 18 ) | ||||||
40 | : | 18 | = | 2 | remainder ( 4 ) | ||||||
18 | : | 4 | = | 4 | remainder ( 2 ) | ||||||
4 | : | 2 | = | 2 | remainder ( 0 ) | ||||||
GCD = 2 |
This solution can be visualized using a Venn diagram.
The GCD equals the product of the numbers at the intersection.