## Sieve of Atkin Maple

Hi

I've been attempting to program the sieve of atkin into Maple 13 but so for I am failing miserably.

primeSieve:= proc(n)
local S,T,j,x,y;
S:=[seq(1..n)];
T:=[2,3,5];
for j in S do
while j mod 60 = 1,13,17,29,37,41,49,53 do
for x in S and y in S do
if 4*x^2+y^2 = j then
T:=T,x,y;
end if;
end do;
end do;
while j mod 60 = 7,19,31,43 do
for x in S and y in S do
if 3*x^2+y^2 = j then
T:=T,x,y;
end if;
end do;
end do;
while j mod 60 = 11,23,47,59 do
for x in S and y in S while x < y do
if 3*x^2-y^2 = j then
T:=T,x,y;
end if;
end do;
end do;
end do;
return S;
end proc;

This is my code up to a certain point. I do realise this isn't the full sieve and this code itself does not run. Could someone help me construct the rest of the code?

My reason for doing this is to calculate primes less than 2*10^6 and it must be fast, i.e less than about 400 secs at the moment although under 100secs is my ultimate goal.

Thanks.