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