login
a(1) = 1, a(2) = 3, for n >= 3, a(n) = smallest prime > a(n-1) such that a(n) mod a(n-1) = a(n-2).
3

%I #12 Dec 21 2023 15:03:31

%S 1,3,7,17,41,181,1489,18049,218077,1326511,69196649,3045979067,

%T 67080736123,942176284789,15141901292747,31225978870283,

%U 577209520957841,9266578314195739,575105065001093659,5760317228325132329,104260815174853475581,3967671293872757204407

%N a(1) = 1, a(2) = 3, for n >= 3, a(n) = smallest prime > a(n-1) such that a(n) mod a(n-1) = a(n-2).

%C a(390) has 1001 digits. - _Michael S. Branicky_, Dec 21 2023

%H Michael S. Branicky, <a href="/A175094/b175094.txt">Table of n, a(n) for n = 1..389</a>

%t nmax= 13; a[1]=1; a[2]=3; kmin=1; For[n=3, n<=nmax, n++, For[k=kmin, k>0, k++, If[Mod[Prime[k],a[n-1]]==a[n-2], a[n]=Prime[k]; kmin=k; k=-1]]]; Array[a,nmax] (* _Stefano Spezia_, Sep 16 2022 *)

%o (Python)

%o from gmpy2 import is_prime

%o from itertools import count, islice

%o def agen(): # generator of terms

%o c, b = 1, 3

%o yield from [c, b]

%o for n in count(3):

%o a = next(c + b*i for i in count(1) if is_prime(c+b*i))

%o c, b = b, a

%o yield a

%o print(list(islice(agen(), 22))) # _Michael S. Branicky_, Dec 21 2023

%Y Cf. A175093, A175207, A175208.

%K nonn

%O 1,2

%A _Jaroslav Krizek_, Jan 31 2010

%E Definition corrected by _Stefano Spezia_, Sep 16 2022

%E a(14) and beyond from _Michael S. Branicky_, Dec 21 2023