cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A354386 a(n) is the first prime that is the start of a sequence of exactly n primes under the map p -> p + A001414(p-1) + A001414(p+1).

This page as a plain text file.
%I A354386 #11 May 30 2022 10:30:32
%S A354386 3,2,337,2633,14143,6108437,373777931
%N A354386 a(n) is the first prime that is the start of a sequence of exactly n primes under the map p -> p + A001414(p-1) + A001414(p+1).
%e A354386 a(3) = 337 because 337, 337+A001414(336)+A001414(338) = 383, and 383+A001414(382)+A001414(384) = 593 are prime, but 593+A001414(592)+A001414(594) = 660 is not prime, and 337 is the first prime for which this works.
%p A354386 spf:= proc(n) option remember; local t; add(t[1]*t[2], t=ifactors(n)[2]) end proc:
%p A354386 f:= n -> spf(n-1)+n+spf(n+1):
%p A354386 g:= proc(n) option remember;
%p A354386   if not isprime(n) then return 0 fi;
%p A354386   1 + procname(f(n))
%p A354386 end proc:
%p A354386 V:= Vector(7): count:= 0:
%p A354386 p:= 1:
%p A354386 while count < 7 do
%p A354386   p:= nextprime(p);
%p A354386   v:= g(p);
%p A354386   if V[v] = 0 then V[v]:= p; count:= count+1 fi;
%p A354386 od:
%p A354386 convert(V,list);
%t A354386 f[1] = 0; f[n_] := Plus @@ Times @@@ FactorInteger[n]; g[n_] := -1 + Length @ NestWhileList[# + f[# - 1] + f[# + 1] &, n, PrimeQ]; seq[len_, max_] := Module[{s = Table[0, {len}], c = 0, p = 1, i}, While[p < max && c < len, p = NextPrime[p]; i = g[p]; If[i <= len && s[[i]] == 0, c++; s[[i]] = p]]; s]; seq[6, 10^7] (* _Amiram Eldar_, May 29 2022 *)
%o A354386 (Python)
%o A354386 from sympy import factorint, isprime, nextprime
%o A354386 def A001414(n): return sum(p*e for p, e in factorint(n).items())
%o A354386 def f(p): return p + A001414(p-1) + A001414(p+1)
%o A354386 def a(n):
%o A354386     p, count = 1, 0
%o A354386     while count != n:
%o A354386         p = nextprime(p)
%o A354386         fp, count = f(p), 1
%o A354386         while isprime(fp): fp = f(fp); count += 1
%o A354386     return p
%o A354386 print([a(n) for n in range(1, 6)]) # _Michael S. Branicky_, May 29 2022
%Y A354386 Cf. A001414, A127305.
%K A354386 nonn,more
%O A354386 1,1
%A A354386 _J. M. Bergot_ and _Robert Israel_, May 24 2022