Ten primes, each less than 3000, form an arithmetic progression. Find them.
10 repeat
20 N=nxtprm(N):Ct=Ct+1
30 until N>3000
40 NoPrimes=Ct-1
50 for Sub1=1 to NoPrimes-9
60 for Sub2=NoPrimes to Sub1+9 step -1
70 if (prm(Sub2)-prm(Sub1))@9=0 then
80 :Good=1
90 :Increm=int((prm(Sub2)-prm(Sub1))/9)
100 :for I=1 to 8
110 :if prmdiv(prm(Sub1)+I*Increm)<prm(Sub1)+I*Increm then Good=0:endif
120 :next
130 :if Good then
140 :for I=0 to 9
150 :print prm(Sub1)+I*Increm;
151 :P=prm(Sub1)+I*Increm
152 :for J=1 to NoPrimes
153 :if prm(J)=P then print "(";cutspc(str(J));")":endif
154 :next
160 :next
165 :print:print Increm
170 :endif
180 next
190 next
Finds a sequence starting at 199 in increments of 210:
199 (46)
409 (80)
619 (114)
829 (145)
1039 (175)
1249 (204)
1459 (232)
1669 (263)
1879 (289)
2089 (316)
The program checks all pairs of primes in the given range and sees if they differ by a multiple of 9. If so, each intervening 1/9 of the way over is checked for primality. If all of them are prime, the result prints.
|
Posted by Charlie
on 2008-09-30 13:16:46 |