Course Computational Mathematics
Sieve of Eratosthenes
In this lesson, we'll learn about the Sieve of Eratosthenes and some of its applications. We will solve the following base problem:
Given two numbers and a sequence of integers , for every number in this sequence, you need to say whether it is prime or not
As we saw in the previous lesson, we can answer whether is prime in . Then using the method we already know, our complexity will be .
#include <iostream>
using namespace std;
int main()
{
int q, n;
cin >> q >> n;
for (int i = 0; i < q; i++)
{
int v;
cin >> v;