%I #20 Oct 12 2022 04:31:23
%S 4,15,17,19,29,57,77,285,318,354,379,405,520,521,595,625,938,1706,
%T 1738,2085,2345,2817,4319,4529,7005,8207,8232,9451,9839,11044,11170,
%U 12386,12421,12722,14153,15220,15371,17052,17965,18279,18811,19890,21628,22667,22746
%N a(n) = smallest number > a(n-1) such that a(1)*a(2)*...*a(n) + 1 and a(1)*a(2)*...*a(n) - 1 are primes.
%H Amiram Eldar, <a href="/A051956/b051956.txt">Table of n, a(n) for n = 1..184</a>
%t a[1] = 4; a[n_] := a[n] = For[k = a[n-1]+1, True, k++, p = Times @@ Array[a, n-1]; If[PrimeQ[k*p+1] && PrimeQ[k*p-1], Print[k]; Return[k]]]; Array[a, 45] (* _Jean-François Alcover_, Oct 23 2016 *)
%o (PARI) lista(nn) = {my (v = vector(nn)); for (n = 1, nn, if (n == 1, p = 1; k = 0; , p = prod(j=1, n-1, v[j]); k = v[n-1]+1); while (! isprime(p*k+1) || ! isprime(p*k-1), k++); v[n] = k; print1(k, ", "););} \\ _Michel Marcus_, Sep 28 2013
%Y Cf. A051935, A051957.
%K nice,nonn
%O 1,1
%A _Felice Russo_, Dec 21 1999
%E More terms from _Michel Marcus_, Sep 28 2013