login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A030665 Smallest nontrivial extension of n which is prime. 10

%I #39 Nov 11 2020 18:32:28

%S 11,23,31,41,53,61,71,83,97,101,113,127,131,149,151,163,173,181,191,

%T 2003,211,223,233,241,251,263,271,281,293,307,311,3203,331,347,353,

%U 367,373,383,397,401,419,421,431,443,457,461,479,487,491,503,5101

%N Smallest nontrivial extension of n which is prime.

%C The argument in A069695 shows that a(n) always exists. - _N. J. A. Sloane_, Nov 11 2020

%H Chai Wah Wu, <a href="/A030665/b030665.txt">Table of n, a(n) for n = 1..10000</a> [T. D. Noe computed the first 1000 terms]

%H Chai Wah Wu, <a href="http://arxiv.org/abs/1503.08883">On a conjecture regarding primality of numbers constructed from prepending and appending identical digits</a>, arXiv:1503.08883 [math.NT], 2015.

%H <a href="/index/Pri#piden">Index entries for primes involving decimal expansion of n</a>

%e For n = 1, we could append 1, 3, 7, 9, 01, etc., to make a prime, but 1 gives the smallest of these, 11, so a(1) = 11.

%e For n = 2, although 2 is already prime, the definition requires an appending at least one digit. 1 doesn't work because 21 = 3 * 7, but 3 does because 23 is prime. Hence a(2) = 23.

%p f:= proc(n) local x0, d, r, y;

%p for d from 1 do

%p x0:= n*10^d;

%p for r from 1 to 10^d-1 by 2 do

%p if isprime(x0+r) then

%p return(x0+r)

%p fi

%p od

%p od

%p end proc:

%p seq(f(n), n=1..100); # _Robert Israel_, Dec 23 2014

%t A030665[n_] := Module[{d = 10, nd = 10 * n}, While[True, x = NextPrime[nd]; If[x < nd + d, Return[x]]; d *= 10; nd *= 10]]; Array[A030665, 100] (* _Jean-François Alcover_, Oct 19 2016, translated from _Chai Wah Wu_'s Python code *)

%o (Python)

%o from sympy import nextprime

%o def A030665(n):

%o d, nd = 10, 10*n

%o while True:

%o x = nextprime(nd)

%o if x < nd+d:

%o return int(x)

%o d *= 10

%o nd *= 10 # _Chai Wah Wu_, May 24 2016

%Y Cf. A018800, A068695, A077501.

%K nonn,base,nice

%O 1,1

%A _Patrick De Geest_

%E Corrected by _Ray Chandler_, Aug 11 2003

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 10:43 EDT 2024. Contains 371967 sequences. (Running on oeis4.)