login
a(1) = 1, a(n) = smallest number greater than a(n-1) such that a(n-1)*a(n) + 1 is prime.
6

%I #18 Dec 13 2018 10:42:24

%S 1,2,3,4,7,10,13,24,25,28,34,37,40,43,46,51,56,60,67,70,79,84,87,94,

%T 105,106,120,126,130,133,136,147,148,151,156,161,162,163,166,171,176,

%U 177,184,190,193,204,208,211,228,234,239,242,248,252,256,262,265,270

%N a(1) = 1, a(n) = smallest number greater than a(n-1) such that a(n-1)*a(n) + 1 is prime.

%C See A073666 for a nonincreasing version and A096100 for a more restrictive constraint. - _M. F. Hasler_, Nov 24 2015

%H Harvey P. Dale, <a href="/A081942/b081942.txt">Table of n, a(n) for n = 1..1000</a>

%t f[s_List] := Block[{k = m = s[[-1]]}, k++; While[ !PrimeQ[k*m + 1], k++]; Append[s, k]]; Nest[f, {1}, 57] (* _Robert G. Wilson v_, Dec 02 2012 *)

%t smp[n_]:=Module[{m=n+1},While[!PrimeQ[m*n+1],m++];m]; NestList[smp,1,60] (* _Harvey P. Dale_, Dec 12 2018 *)

%o (PARI) A081942(n,show=0,a=1)={for(n=2,n,show&&print1(a",");for(k=a+1,9e9, isprime(a*k+1) && (a=k) && break));a} \\ Use 2nd or 3rd optional arg to print intermediate terms or to use another starting value. - _M. F. Hasler_, Nov 24 2015

%Y Cf. A081943, A073666, A096100.

%K nonn

%O 1,2

%A _Amarnath Murthy_, Apr 02 2003

%E More terms from Gabriel Cunningham (gcasey(AT)mit.edu), Apr 08 2003