|
MATHEMATICA
|
step[{list_, q_}] := Module[{p=NextPrime[q]}, {Join[list, If[PrimeQ[p+2], {{p, p+2}}, {}]], p}]
smallerTwin[n_] := First[Transpose[First[NestWhile[step, {{{3, 5}}, 3}, Length[First[step[#]]]<=n&]]]]
a097489[n_] := Rest[FoldList[Times, 1, smallerTwin[n]]]
a097490[n_] := Select[Map[#+2&, a097489[n]], PrimeQ]
|
|
PROG
|
(PARI) fp(n) = p=1; for(x=1, n, p*=twinl(x); if(isprime(p+2), print1(p+2", ")))
twinl(n) = { local(c, x); c=0; x=1; while(c<n, if(isprime(prime(x)+2), c++); x++; ); return(prime(x-1)) }
|