|
MATHEMATICA
|
a = {4, 6, 12, 18, 30, 42, 60, 72, 102, 108, 138, 150} (* A014574 *); Table[ Product[a[[k]]^2 - 1, {k, 1, n}], {n, 1, 12}]
Rest[FoldList[Times, 1, Times@@@Select[Partition[Prime[Range[50]], 2, 1], #[[2]]-#[[1]]==2&]]] (* Harvey P. Dale, Jan 19 2015 *)
step[{list_, q_}] := Module[{p=NextPrime[q]}, {Join[list, If[PrimeQ[p+2], {{p, p+2}}, {}]], p}]
pairList[n_] := First[NestWhile[step, {{{3, 5}}, 3}, Length[First[step[#]]]<=n&]]
a037074[n_] := Map[Apply[Times, #]&, pairList[n]]
a074040[n_] := Rest[FoldList[Times, 1, a037074[n]]]
|