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.

A030670 Smallest prime formed by appending a number to the n-th prime.

This page as a plain text file.
%I A030670 #38 Jan 27 2025 20:01:26
%S A030670 23,31,53,71,113,131,173,191,233,293,311,373,419,431,479,5323,593,613,
%T A030670 673,719,733,797,839,8923,971,1013,1031,10711,1091,11311,1277,1319,
%U A030670 1373,1399,1493,1511,1571,1637,16729,1733,17911,1811,1913,1931
%N A030670 Smallest prime formed by appending a number to the n-th prime.
%C A030670 Previous name: Smallest prime whose decimal expansion begins (nontrivially) with the n-th prime.
%C A030670 Add digits to p (starting with a nonzero digit) until another prime is reached.
%C A030670 This differs from A064792 in that there the appended digits may start with a 0. The first difference occurs at a(16) = 5323, while A064792(16) = 5303. - _M. F. Hasler_, Jan 15 2025
%H A030670 Robert Israel, <a href="/A030670/b030670.txt">Table of n, a(n) for n = 1..10000</a>
%e A030670 a(16) = 5323 because 53 is the 16th prime, and 23 is the smallest number that can be appended to 53 to give another prime. 5303 is not allowed because 03 starts with zero. - _David Radcliffe_, Jan 08 2025
%p A030670 f:= proc(p) local d,x;
%p A030670   for d from 1 do
%p A030670     x:= nextprime(10^d*p+10^(d-1)-1);
%p A030670     if x < 10^d*(p+1) then return x fi
%p A030670   od
%p A030670 end proc:
%p A030670 map(f @ ithprime, [$1..100]); # _Robert Israel_, Aug 12 2018
%t A030670 f[n_] := Block[{k = 1, p = Prime@ n}, While[a = 10^Floor[1 + Log10@ k] p + k; !PrimeQ@ a, k += 2]; a]; Array[f, 44]
%o A030670 (Python)
%o A030670 from sympy import prime, isprime
%o A030670 from itertools import count
%o A030670 def a030670(n):
%o A030670   p = str(prime(n))
%o A030670   return next(x for k in count(1) if isprime(x:=int(p+str(k)))) # _David Radcliffe_, Jan 08 2025
%o A030670 (PARI) apply( {A030670(n)=n=prime(n);for(L=1,oo, n*=10; forstep(s=bitor(10^(L-1),1),10^L-1,2, isprime(n+s)&& return(n+s)))}, [1..44]) \\ _M. F. Hasler_, Jan 15 2025
%Y A030670 See A064792 for another version. Note that A064792 <= a(n). Cf. A065112, A178220.
%K A030670 nonn,base
%O A030670 1,1
%A A030670 _Patrick De Geest_
%E A030670 Title changed by _David Radcliffe_, Jan 08 2025