10 FirstPrime=2
20 while FirstPrime<500
30 for N=2 to 9
40 T=0
50 P=FirstPrime
60 for I=1 to N
70 T=T+P
80 LastPrime=P
90 P=nxtprm(P)
100 next I
110 Sr=int(sqrt(T)+0.5)
120 if Sr*Sr=T and prmdiv(Sr)=Sr then print FirstPrime;LastPrime;N,T;Sr
130 next N
140 FirstPrime=nxtprm(FirstPrime)
150 wend
doesn't check to see that the subsequent primes fall under 500 but in fact all do, as shown in the printout that, among other things shows the last prime in each sequence:
first last N sum square
prime prime root
13 19 3 49 7
13 37 7 169 13
37 43 3 121 11
73 109 9 841 29
181 199 5 961 31
227 269 9 2209 47
277 283 3 841 29
293 337 7 2209 47
313 331 3 961 31
317 349 5 1681 41
To see all the primes involved rather than just the first and last, below, all the summed primes are listed on a line below each main report line:
13 19 3 49 7
13 17 19
13 37 7 169 13
13 17 19 23 29 31 37
37 43 3 121 11
37 41 43
73 109 9 841 29
73 79 83 89 97 101 103 107 109
181 199 5 961 31
181 191 193 197 199
227 269 9 2209 47
227 229 233 239 241 251 257 263 269
277 283 3 841 29
277 281 283
293 337 7 2209 47
293 307 311 313 317 331 337
313 331 3 961 31
313 317 331
317 349 5 1681 41
317 331 337 347 349
|
Posted by Charlie
on 2011-03-06 18:09:43 |