What is the problem you are having?
eliminating the multiples
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
var list : array 2 .. n of int
put skip
for i : 2 .. n
put i : 5 ..
end for
put skip
put skip
for i : 2 .. n
if i mod 2 >= 1 then
put i : 5 ..
end if
end for
put skip
for i : 2 .. n
if i mod 3 >= 1 then
put i : 5 ..
end if
end for
|
when i give n value as 8, it outputs
Quote:
2 , 3 , 4 , 5 , 6 , 7 , 8
% Eliminates all the multiples of 2 in the row below
3 , 5 , 7
% Eliminates all the multiples of 3 in the row below
2 , 4 , 5 , 7 , 8
as u cud see, the program eliminated the multiples of 2 in second row using the first row list. then the program eliminated the multiples of 3 in third row using the first row list. I want the program to eliminate the multiples of 3 using the second row list. Juz like tht i wanna eliminate multiples of 5 using the previous list.
Please help me ASAP
and cud u please tell me how to repeat multiples by itself. i dont wanna use different for loops for mod 2, mod 3, mod 5, mod 7..
it says "The process continues until it is no longer possible to eliminate any multiples of values that are left in the table. The remaining values must be prime."
this is project is due in 2 days so please help as soon as possible
thanks a lot