> Primes # Various Prime Number Programs  Header by J.G.Harston W79 (: 2 :'"Press a key";: <#7:7"Prime Number Generation" F'"Press a key:" PG'"1: R.Harker's original. Tests all"'4"numbers with all numbers" ZV'"2: Peter Davy's improvement. Tests and"'4"uses only odd numbers up to SQR(x)" dK'"3: J.G.Harston's improvement. Only uses"4"6n-1, 6n+1 up to SQR(x)" n,'"4: J.G.Harston's fast integer primes" xF'"5: J.G.Harston's quadratic integer"'4"primes using y=x^2+x+41" )'"6: J.G.Harston's IsPrime function" '"0: Exit" #A$=:"0123456",A$):A$="0": +A$="Primes"+A$:'A$;:A%=line(A$)::A% : ݤline(A$):A%=+3*(?(P-3)=0)::A%=A%+4+$A%:($A%,&F4)>0 $A%,A$)>0) A%>P:A%>P:=0 =(A%!-2)(255*(1+((?(P-3)=0)&100)))+(A%?-3)*((?(P-3)<>0)&100) : 'Split:S%=0:A$="":A%=+4+$(+4): A%=A%+4+$A% )($A%,&F4)>0 $A%,">")>1) A%>P cS% A$<>"":M%=A%?-3:A%?-3=&FF:"SAVE "+A$+" "+~S%+" "+~(A%-2)+" FFFF0000 FFFFFB00":A%?-3=M% )S%=A%-4:A$=$A%,1+$A%,">")):A%>P: : NA%=0:*KEY 0 A%=A%+1:OS."LOAD Primes"+STR$(A%)+" "+STR$~(TOP-2):END|MREN.|M : : ": , > Primes1 6( D6E (R. Harker)'s original version @0 J place=1 T divisable=0 ^ number=0 h T%=: r divisable=1 number |) (number divisable)=0 a=a+1 ! a>2 divisable=number 7 (number 2=0 number>2) divisable=number  divisable N a=2 number;" Is prime number ";place;" after ";(-T%)/100;" secs"  a=2 place=place+1  a=0  number=number+1  : : :  > Primes2 ( K2K (Peter Davy)'s modification of , D6E (R. Harker)'s Prime Number program 0 8 2;" is prime number ";1: 3;" is prime number ";2 & number%=5 0 try%=1 : order%=2 D T%=: N X try%=try%+2 b9 (number% try%)=0 factorfound= factorfound= l$ factorfound try%>(number%) vz factorfound try%>(number%) order%=order%+1: number%;" is prime number ";order%;" after ";(-T%)/100;" secs"  number%=number%+2:try%=1  : : : :  > Primes3 0 ) W79 (J.G.Harston)'s modification to ( K2K (Peter Davy)'s modification to & D6E (R. Harker)'s Primes program : 8 2;" is prime number ";1: 3;" is prime number ";2  number%=5:number_inc%=2  order%=2  T%=:   try%=1:try_inc%=4 *2 factorfound=(number% 2)=0 (number% 3)=0 4~ factorfound :try%=try%+try_inc%:try_inc%=6-try_inc%:factorfound=(number% try%)=0: factorfound try%>(number%) >{ (factorfound try%<=(number%)) order%=order%+1: number%;" is prime number ";order%;" after ";(-T%)/100;" secs" H: number%=number%+number_inc%:number_inc%=6-number_inc% R \: f: p: z:  > Primes4 0 21-09-96 JGH: Fast 6n-1, 6n+1 prime lister : 8128:2;" is prime number 1":3;" is prime number 2" N%=5:I%=2:O%=2:T%=: GD%=1:A%=4:F%=:(N%3):D%=D%+A%:A%=6-A%:F%=(N%D%)=0:F% D%>=N% T(F% D%<=N%):O%=O%+1:N%;" is prime number ";O%;" after ";(-T%)/100;" secs" N%=N%+I%:I%=6-I%: : :  > Primes5 . 19-09-96 JGH: Fast quadratic combination :  128:O%=3 %2;" is prime 1":3;" is prime 2" N%=5:I%=2:O%=2:T%=: $6F%=:N%>42 N%<1602:N=((4*N%-163)-1)/2:F%=N<>N .TF%=F%((N%3)=0):D%=1:J%=4:F%: D%=D%+J%:J%=6-J%:F%=(N% D%)=0:F% D%>=(N%) 8O(F% D%<=(N%)):O%=O%+1:N%;" is prime ";O%;" after ";(-T%)/100;" secs" BN%=N%+I%:I%=6-I%: L: V: `: j: t: ~ > Primes6 2 21-09-96 JGH: Function to test for primeness : 0:N%=5:I%=2:O%=2:T%=: NNum_IsPrime(N%):O%=O%+1:N%;" is prime ";O%;" after ";(-T%)/100;" secs" N%=N%+I%:I%=6-I%: : :ݤNum_IsPrime(N%): N,D%,K%,F%:(N%2)=0 (N%3)=0:= 1N%>42 N%<1602:N=((4*N%-163)-1)/2:N=N:= RD%=1:J%=4: D%=D%+J%:J%=6-J%:F%=(N% D%)=0:F% D%>=(N%):=(F% D%<=(N%)) : :