I really have hard time understanding these functions. Can anyone with good know
ID: 3620546 • Letter: I
Question
I really have hard time understanding these functions.Can anyone with good knowledge explain line by line what it is doing ? (Assuming the size can be any number between 2 and 10000)
void runsieve(int size)
{
/* replace 1 with 0 at each index which is not a prime */
int top=(int)sqrt(size);
int i,k;
/* remove all multiples of i, i=2....top */
for(i=2; i<=top; i++)
if(sieve[i]) /* new only for prime i */
for(k=2*i; k<=size; k+=i)
sieve[k]=0;
}
void printsieve(int size)
{
int i;
for(i=2; i<=size; i++)
if(sieve[i]) /* if i is marked prime */
printf("%5d", i);
}