10DEFFNS="PRIMES"
20MODE7
30VDU23;8202;0;0;0;
40PRINTCHR$132;CHR$157;CHR$131;CHR$14
1;"Prime Numbers "
50PRINTCHR$132;CHR$157;CHR$131;CHR$14
1;"Prime Numbers "
60PRINTTAB(10,23);CHR$131;"by Andrew
Medworth"
70VDU28,0,21,39,3
80PRINTCHR$130;"This prints all terms
in the sequence"
90PRINTCHR$130;"x^2+x+41 and marks th
em blue if they"
100PRINTCHR$130;"are prime, leaving th
em white if not."
101PRINTCHR$131;"Other sequences to tr
y are n^2+n+17"
102PRINTCHR$131;"and 2(n^2)+29. Just c
hange line 180."
110PRINT''CHR$129;"Press SPACE to star
t."
120
130REPEAT UNTIL GET=32
140CLS
150:
160VDU7
170n=1
180t%=n^2+n+41
190IF FNIsPrime(t%)=TRUE THEN PRINT" T
erm ";n;" is ";t% ELSE PRINT" Term ";n;"
is ";t%
200n=n+1:GOTO 180
210:
220DEFFNIsPrime(N%):LOCAL N,D%,K%,F%:I
F(N%MOD2)=0 OR (N%MOD3)=0:=FALSE
230IFN%>42 AND N%<1602:N=(SQR(4*N%-163
)-1)/2:IFN=INTN:=TRUE
240D%=1:J%=4:REPEAT D%=D%+J%:J%=6-J%:F
%=(N% MOD D%)=0:UNTILF% OR D%>=SQR(N%):=
NOT(F% AND D%<=SQR(N%))