🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Number Theory for Coding: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Why does Euclid's algorithm use gcd(a, b) = gcd(b, a % b)?
  2. Q2. What does this print? (code)
  3. Q3. To check whether n is prime, why is it enough to try divisors up to √n?
  4. Q4. In the Sieve of Eratosthenes, why start crossing out multiples of p from p × p?
  5. Q5. What does this print? (code)
  6. Q6. 72 = 2³ × 3². How many divisors does 72 have?
  7. Q7. Why do problems often ask for the answer modulo 10⁹ + 7?
  8. Q8. What does this print? (code)
  9. Q9. How many loop steps does fast power take for an exponent e?
  10. Q10. Under modulo M = 10⁹ + 7, how do you correctly compute (a / b) mod M?