🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)?

  1. A.Because a % b is always prime
  2. B.Any common divisor of a and b also divides a % b, so the GCD stays the same while the numbers shrink
  3. C.Because it works only when a is even
  4. 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 →