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-2 of 2 results.

A030665 Smallest nontrivial extension of n which is prime.

Original entry on oeis.org

11, 23, 31, 41, 53, 61, 71, 83, 97, 101, 113, 127, 131, 149, 151, 163, 173, 181, 191, 2003, 211, 223, 233, 241, 251, 263, 271, 281, 293, 307, 311, 3203, 331, 347, 353, 367, 373, 383, 397, 401, 419, 421, 431, 443, 457, 461, 479, 487, 491, 503, 5101
Offset: 1

Views

Author

Keywords

Comments

The argument in A069695 shows that a(n) always exists. - N. J. A. Sloane, Nov 11 2020

Examples

			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.
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.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local x0, d, r, y;
       for d from 1 do
         x0:= n*10^d;
         for r from 1 to 10^d-1 by 2 do
           if isprime(x0+r) then
              return(x0+r)
           fi
         od
       od
    end proc:
    seq(f(n), n=1..100); # Robert Israel, Dec 23 2014
  • Mathematica
    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 *)
  • PARI
    apply( {A030665(n)=my(p,L); until(n+10^L++>p=nextprime(n), n*=10);p}, [1..55]) \\ M. F. Hasler, Jan 27 2025
  • Python
    from sympy import nextprime
    def A030665(n):
        d, nd = 10, 10*n
        while True:
            x = nextprime(nd)
            if x < nd+d:
                return int(x)
            d *= 10
            nd *= 10 # Chai Wah Wu, May 24 2016
    

Extensions

Corrected by Ray Chandler, Aug 11 2003

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
Showing 1-2 of 2 results.