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.

Showing 1-4 of 4 results.

A068695 Smallest number (not beginning with 0) that yields a prime when placed on the right of n.

Original entry on oeis.org

1, 3, 1, 1, 3, 1, 1, 3, 7, 1, 3, 7, 1, 9, 1, 3, 3, 1, 1, 11, 1, 3, 3, 1, 1, 3, 1, 1, 3, 7, 1, 17, 1, 7, 3, 7, 3, 3, 7, 1, 9, 1, 1, 3, 7, 1, 9, 7, 1, 3, 13, 1, 23, 1, 7, 3, 1, 7, 3, 1, 3, 11, 1, 1, 3, 1, 3, 3, 1, 1, 9, 7, 3, 3, 1, 1, 3, 7, 7, 9, 1, 1, 9, 19, 3, 3, 7, 1, 23, 7, 1, 9, 7, 1, 3, 7, 1, 3, 1, 9, 3, 1
Offset: 1

Views

Author

Amarnath Murthy, Mar 03 2002

Keywords

Comments

Max Alekseyev (see link) shows that a(n) always exists. Note that although his argument makes use of some potentially large constants (see the comments in A060199), the proof shows that a(n) exists for all n. - N. J. A. Sloane, Nov 13 2020
Many numbers become prime by appending a one-digit odd number. Some numbers (such as 20, 32, 51, etc.) require a 2-digit odd number (A032352 has these). In the first 100000 values of n there are only 22 that require a 3-digit odd number (A091089). There probably are some values that require odd numbers of 4 or more digits, but these are likely to be very large. - Chuck Seggelin, Dec 18 2003

Examples

			a(20)=11 because 11 is the minimum odd number which when appended to 20 forms a prime (201, 203, 205, 207, 209 are all nonprime, 2011 is prime).
		

Crossrefs

Cf. A032352 (a(n) requires at least a 2 digit odd number), A091089 (a(n) requires at least a 3 digit odd number).
Cf. also A060199, A228325, A336893.

Programs

  • Mathematica
    d[n_]:=IntegerDigits[n]; t={}; Do[k=1; While[!PrimeQ[FromDigits[Join[d[n],d[k]]]],k++]; AppendTo[t,k],{n,102}]; t (* Jayanta Basu, May 21 2013 *)
    mon[n_]:=Module[{k=1},While[!PrimeQ[n*10^IntegerLength[k]+k],k+=2];k]; Array[mon,110] (* Harvey P. Dale, Aug 13 2018 *)
  • PARI
    A068695=n->for(i=1,oo,ispseudoprime(eval(Str(n,i)))&&return(i)) \\ M. F. Hasler, Oct 29 2013
    
  • Python
    from sympy import isprime
    from itertools import count
    def a(n): return next(k for k in count(1) if isprime(int(str(n)+str(k))))
    print([a(n) for n in range(1, 103)]) # Michael S. Branicky, Oct 18 2022

Extensions

More terms from Chuck Seggelin, Dec 18 2003
Entry revised by N. J. A. Sloane, Feb 20 2006
More terms from David Wasserman, Feb 14 2006

A228323 a(1)=1; thereafter a(n) is the smallest number m not yet in the sequence such that at least one of the concatenations a(n-1)||m or m||a(n-1) is prime.

Original entry on oeis.org

1, 3, 2, 9, 5, 21, 4, 7, 6, 13, 10, 19, 16, 27, 8, 11, 15, 23, 12, 17, 20, 29, 14, 33, 26, 47, 18, 31, 25, 39, 22, 37, 24, 41, 30, 49, 34, 57, 28, 43, 36, 59, 32, 51, 38, 53, 42, 61, 45, 67, 58, 69, 55, 63, 44, 81, 35, 71, 48, 77, 50, 87, 62, 99, 40, 73, 46
Offset: 1

Views

Author

N. J. A. Sloane, Aug 20 2013

Keywords

Comments

Does every number appear in the sequence?
If a(n) is coprime to 10, then a(n+1) exists by Dirichlet's theorem. - Eric M. Schmidt, Aug 20 2013 [In more detail: let a(n) have d digits, and consider the arithmetic progression k*10^d + a(n), and apply Dirichlet's theorem. This gives a number k such that the concatenation k||a(n) is prime. N. J. A. Sloane, Nov 08 2020]
The argument in A068695 shows that a(n) always exists. - N. J. A. Sloane, Nov 11 2020

Crossrefs

See A228324 for the primes that arise.

Programs

  • Mathematica
    f[s_] := Block[{k = 2, idj = IntegerDigits@ s[[-1]]}, While[idk = IntegerDigits@ k; MemberQ[s, k] || ( !PrimeQ@ FromDigits@ Join[idj, idk] && !PrimeQ@ FromDigits@ Join[idk, idj]), k++]; Append[s, k]]; Nest[f, {1}, 66] (* Robert G. Wilson v, Aug 20 2013 *)
  • Python
    from sympy import isprime
    from itertools import islice
    def c(s, t): return isprime(int(s+t)) or isprime(int(t+s))
    def agen():
        aset, k, mink = set(), 1, 2
        while True:
            an = k; aset.add(an); yield an; s, k = str(an), mink
            while k in aset or not c(s, str(k)): k += 1
            while mink in aset: mink += 1
    print(list(islice(agen(), 56))) # Michael S. Branicky, Oct 17 2022

Extensions

More terms from Alois P. Heinz, Aug 20 2013

A338366 a(n) = smallest positive number k with all digits equal such that the concatenation k||n||k is prime, or -1 if no such k exists.

Original entry on oeis.org

1, 3, 7, 1, 11, 1, 7777, 3, 1, 1, 9, -1, 7, 33, 99, 1, 3, 1, 1, 9, 1, 11, -1, 1, 7, 3, 7777777777, 1111, 111, 1, 1, 3, 1, -1, 3, 33, 1, 3, 1, 77777777777777, 111, 3, 1111111111111111111111111111111111111111, 3, -1, 1, 3, 1, 1, 999, 7, 1, 11, 1, 7, -1, 33, 1, 3, 3, 1, 3, 1
Offset: 0

Views

Author

N. J. A. Sloane, Nov 08 2020

Keywords

Comments

See A090287 for more information.
From Robert Price, Sep 20 2023: (Start)
For a(366), k is a string of 8441 1's.
The sequence then continues: 77, 1, 1, 3, 1, 1, 9, 7777777, 1, 11, 3, 1, 11, 9, 77, 11111, 1, 1, 33333, 3, 7, 9, 3, 1, 77, 1, 1, 9, 7777777777 until a(396) where k is a sequence of 269 1's.
The sequence then continues: 9, 777, 11, 9, 1, 7, 3, 7, 1, 11, 1, 1, 9, 9, 1111, 3, 999, 77777, 99, 7, 7, 3, 7, -1, 3, 1, 11, 77, 1, 77, 3, 1, 7, 3, 3, 1, 111111, 1, 7, 99, 7, 1111, 9, 1, 1, 11, 1, 7777777, 11, 1, 1111, 3, 1111, 7, 3, 7, 11, 3, 1, 1, 111, 3, 1, 3, 3, 1, 33, 9, 11, 33, 3, 7, 3, 3, 7, 99, 1, 1, 11, 3, 1, 9, 7, 77, 9, 1, 1, 3, 1, 7777, 33, 3, 1, 33, 3, 77, 77, 9, 1, 3, 33, 11111, 9, 9. (End)

Examples

			a(3) = 1 because 131 is prime.
a(4) = 11 because 11411 is prime, and all of 141, 242, 343, ..., 949 are composite.
		

Crossrefs

Cf. A090287.
Related sequences: A010785, A068695, A091088, A228323, A228325, A336893, A338712 (see also the Index link above).

Extensions

More terms from Alois P. Heinz, Nov 08 2020

A245727 Least number k >= 0 such that n concatenated with n + k is prime.

Original entry on oeis.org

0, 1, 4, 3, 4, 1, 2, 1, 2, 3, 6, 1, 6, 9, 8, 3, 4, 5, 12, 7, 8, 15, 10, 13, 6, 7, 2, 5, 10, 7, 6, 19, 10, 15, 4, 1, 2, 9, 4, 9, 12, 1, 6, 3, 2, 3, 4, 13, 2, 1, 2, 9, 28, 17, 2, 1, 22, 3, 22, 7, 2, 1, 4, 5, 4, 7, 12, 1, 2, 9, 6, 11, 20, 3, 2, 5, 12, 1, 14, 1, 10, 5, 4, 37, 12, 3, 16, 5, 10
Offset: 1

Views

Author

Derek Orr, Jul 30 2014

Keywords

Examples

			33 is not prime. 34 is not prime. 35 is not prime. 36 is not prime. 37 is prime. Since 7 is 4 more than 3, a(3) = 4.
		

Crossrefs

Cf. A228325.

Programs

  • Maple
    a:= proc(n) local j; for j from n do if isprime(n*10^(1+ilog10(j))+j) then return(j-n) fi od end proc:
    seq(a(n),n=1..100); # Robert Israel, Jul 30 2014
  • Mathematica
    lnk[n_]:=Module[{k=0,idn=IntegerDigits[n]},While[!PrimeQ[FromDigits[ Join[ idn, IntegerDigits[ n+k]]]],k++];k]; Array[lnk,90] (* Harvey P. Dale, Oct 05 2014 *)
  • PARI
    a(n) = for(k=n,10^4,if(isprime(eval(concat(Str(n),Str(k)))),return(k-n)))
    vector(150,n,a(n))
    
  • Python
    def a(n):
      for k in range(n,10**4):
        if isprime(str(n)+str(k)):
          return k-n
    n = 1
    while n < 150:
      print(a(n),end=', ')
      n += 1

Formula

a(n) = A228325(n) - n for n > 1.
Showing 1-4 of 4 results.