Saturday, June 30, 2012

10 000 primes


clg
graphsize 500,500
color yellow
rect 0,0,500,500
color black
f=0

for h = 3 to 10000
if f=0 then
Prime = h-1
y = int(Prime/100)
x = Prime - y*100 -1
Rect 5*x,5*y,5,5
print Prime
end if


f=0
for i = 2 to int(h/2)+1 step 1
if int(h/i)=h/i then f=1
if int(h/i)=h/i then i=h/2
next i

next h

1 comment:

  1. FYI... when checking for prime you only need to check factors up to the square root of the test number.

    ReplyDelete