unsigned int koren bool prostmask 131072 for unsigned int prostmask ko

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
unsigned int n,koren;
bool prostmask[131072];
for (unsigned int i = 0; i <= n; i++)
{
prostmask[i] = 1;
}
koren = sqrt(n);
for (unsigned int i = 2; i <= koren; i++)
{
if (prostmask[i] == 1)
{
for (unsigned short int j = i * i; j <= n; j = j + i)
{
prostmask[j] = 0;
}
}
}