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

A069691 Smallest prime with internal digits = n; or 0 if no such number exists.

Original entry on oeis.org

101, 113, 127, 131, 149, 151, 163, 173, 181, 191, 1103, 1117, 1123, 2131, 2141, 1151, 1163, 1171, 1181, 1193, 1201, 1213, 1223, 1231, 1249, 1259, 2267, 1277, 1283, 1291, 1301, 1319, 1321, 2333, 2341, 2351, 1361, 1373, 1381, 1399, 1409, 2411, 1423, 1433, 1447
Offset: 0

Views

Author

Amarnath Murthy, Apr 06 2002

Keywords

Comments

By placing one digit on both sides of n one get 36 different numbers that might be primes ( 1 to 9 on left and 1,3,7,9 on right). If none of these numbers is a prime then a(n) = 0.
The smallest value of n for which a(n) = 0 is 2437 = A032734(0). - Rick L. Shepherd and Reinhard Zumkeller, Jul 17 2002

Examples

			a(25) = 1259 is prime with internal digits =25.
		

Crossrefs

Extensions

Corrected and extended by Larry Reeves, Rick L. Shepherd and Reinhard Zumkeller, Jul 17 2002
Showing 1-2 of 2 results.