← Quiz: Number Theory for Coding: all 10 questions
Quiz: Number Theory for Coding · Question 1 of 10
Why does Euclid's algorithm use gcd(a, b) = gcd(b, a % b)?
Why does Euclid's algorithm use gcd(a, b) = gcd(b, a % b)?
- A.Because a % b is always prime
- B.Any common divisor of a and b also divides a % b, so the GCD stays the same while the numbers shrink
- C.Because it works only when a is even
- D.Because a % b is always 1
Answer & explanation
Correct answer: Any common divisor of a and b also divides a % b, so the GCD stays the same while the numbers shrink
The remainder is a minus a multiple of b, so it keeps every common divisor.
Can you get the rest right without peeking?
Take the timed Quiz: Number Theory for Coding quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →