# C code fragment [closed]

In the following C program fragment, j, k, n and TwoLog_n are integer variables, and A is an array of integers. The variable n is initialized to an integer $\ge3$, and TwoLog_n is initialized to the value of $2\lceil\log{2n}\rceil$

for (k=3; k <= n; k++)
A[k] = 0;
for (k=2; k <= TwoLog_n; k++)
for (j=k+1; j <= n; j++)
A[j] = A[j] || (j%k);
for (j=3; j <= n; j++)
if (!A[j]) printf(”%d ”,j);

Can anyone tell me what this piece of code fragment basically does??

-
Have you tried running it? – Luke Mathieson Dec 10 '12 at 7:21
yeah i did. But for evry value i give dere is no answer. dats it none of d values in array A ar zero finally – QueueTank Dec 10 '12 at 7:22
This sounds like a question that is more suitable for codereview.stackexchange.com – Jernej Dec 10 '12 at 8:24
@Jernej I do not think so. codereview.se is for correctness, best practices, design issues etc. Their FAQ explicitly mentions "understanding code snippets" is off-topic. Whether or not it is appropriate for cs.se is something I am not sure of. However, I have seen quite a few similar questions asked and answered here. – Paresh Dec 10 '12 at 9:58

## closed as off topic by Dave Clarke, AProgrammer, Realz Slaw, AJed, MerbsDec 10 '12 at 22:11

Questions on Computer Science Stack Exchange are expected to relate to computer science within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

It appears that it attempts to print all integer values between $3$ and $n$ (inclusive) for which each is completely divisible by all integers in the range $[2,2 \cdot \lceil log_2(n)\rceil]$ less than itself. A finer point is that it preserves the first non zero remainder value discovered in the corresponding array element instead of overriding it with subsequent non zero values. This may simply be an unintended result of coding "shorthand."