Skip to content
Embercode
✕
Number theoryQuick quiz

Euclid and sieves

8 questions. Covers Sieves for primes.

Questions 1 to 5 of 8

  1. 1. An AI tool wrote a linear sieve. It changed the inner loop's stop test from if (p > lp[i] || p * i > n) break; to if (p * i > n) break; and changed nothing else. The program still prints 78498 for the number of primes up to 10^6. What is the problem?
  2. 2. How many primes are there up to 10^6? Give the count.

    Type a number.

  3. 3. The odd-only sieve sets its upper index with half = n / 2 instead of (n - 1) / 2. Which statements about this bug are true?

    Pick every answer that is true.

  4. 4. In C++, what does -7 % 3 evaluate to? Give the number.

    Type your answer.

  5. 5. Put the first three steps of Euclid's algorithm for gcd(1071, 462) in the order they run.

    Use the arrows to put the steps in order.

    1. 1.462 mod 147 = 21
    2. 2.1071 mod 462 = 147
    3. 3.147 mod 21 = 0

4 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.