Cryptography Reference
In-Depth Information
Step 1: Initialization of the variables. The auxiliary function ul_iroot() computes
the integer part of the square root of a ULONG variable. For this it uses the procedure
elucidated in Section 10.3. Then comes the allocation of the vector f for marking
the composite numbers.
B = (1 + ul_iroot (N)) >> 1;
L=N>>1;
if(((N&1)==0)&&(N>0))
{
--L;
}
if ((f = (char *) malloc ((size_t) L+1)) == NULL)
{
return (ULONG *) NULL;
}
for (i = 1; i <= L; i++)
{
f[i] = 1;
}
p=3;
s=4;
Steps 2, 3, and 4 constitute the actual sieve. The variable i represents the
numerical value 2i+1 .
for (i = 1; i <= B; i++)
{
if (f[i])
{
for(k=s;k<=L;k+=p)
{
f[k] = 0;
}
}
s+=p+p+2;
p+=2;
}
Search WWH ::




Custom Search