'********************************************** '* TABLE OF PRIME NUMBERS * '* ------------------------------------------ * '* This small program writes a table of prime * '* numbers from 1 to N (here N=2000). * '* ------------------------------------------ * '* * '* BASIC Version By J-P Moreau. * '* (www.jpmoreau.fr) * '********************************************** DEFINT i-n DIM IPremier(400), IRaye(2000) N = 2000 for i=1 to N IRaye(i)=0 next i IRaye(1) = 1 iprem = 1 10 iprem=iprem+1 if iprem > N or IRaye(iprem)=0 then goto 20 goto 10 20 i = 2*iprem 30 IRaye(i) = 1 i = i + iprem if i<=N then goto 30 if iprem*iprem <= N then goto 10 j = 0 for i=1 to N if IRaye(i)=0 then j=j+1 IPremier(j) = i end if next i m=0 print " Between 1 and ";N;", there are ";j;" prime numbers:" for i=1 to j m=m+1 print IPremier(i); if IPremier(i)<200 then im=17 elseif IPremier(i)<1000 then im=15 else im=13 end if if m=im then print m=0 end if next i print input " ? ", s END 'end of file primes.bas