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