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

A018800 Smallest prime that begins with n.

Original entry on oeis.org

11, 2, 3, 41, 5, 61, 7, 83, 97, 101, 11, 127, 13, 149, 151, 163, 17, 181, 19, 2003, 211, 223, 23, 241, 251, 263, 271, 281, 29, 307, 31, 3203, 331, 347, 353, 367, 37, 383, 397, 401, 41, 421, 43, 443, 457, 461, 47, 487, 491, 503, 5101, 521, 53, 541, 557, 563, 571, 587, 59
Offset: 1

Views

Author

Keywords

Comments

Conjecture: If a(n) = (n concatenated with k) then k < n. - Amarnath Murthy, May 01 2002
a(n) always exists. Proof. Suppose n is L digits long, and consider the numbers between n*10^B and n*10^B+10^C, where B > C are both large compared with L. All such numbers begin with the digits of n. Using the upper and lower bounds on pi(x) from Theorem 1 of Rosser and Schoenfeld, it follows that for sufficiently large B and C, at least one of these numbers is a prime. QED - N. J. A. Sloane, Nov 14 2014

Crossrefs

A164022 is the base-2 analog.
Cf. also A258337.
Row n=1 of A262369.

Programs

  • Haskell
    import Data.List (isPrefixOf, find); import Data.Maybe (fromJust)
    a018800 n = read $ fromJust $
                find (show n `isPrefixOf`) $ map show a000040_list :: Int
    -- Reinhard Zumkeller, Jul 01 2015
    
  • Maple
    f:= proc(n) local x0, d,r,y;
       if isprime(n) then return(n) fi;
       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
    Table[Function[d, FromDigits@ SelectFirst[ IntegerDigits@ Prime@ Range[10^4], Length@ # >= Length@ d && Take[#, Length@ d] == d &]][ IntegerDigits@ n], {n, 59}] (* Michael De Vlieger, May 24 2016, Version 10 *)
  • PARI
    a(n{,base=10}) = for (l=0, oo, forprime (p=n*base^l, (n+1)*base^l-1, return (p))) \\ Rémy Sigrist, Jun 11 2017
    
  • Python
    from sympy import isprime
    def a(n):
        if isprime(n): return n
        pow10 = 10
        while True:
            t, maxt = n * pow10 + 1, (n+1) * pow10
            while t < maxt:
                if isprime(t): return t
                t += 2
            pow10 *= 10
    print([a(n) for n in range(1, 60)]) # Michael S. Branicky, Nov 02 2021

Formula

a(n) = prime(A085608(n)). - Michel Marcus, Oct 19 2013

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

A077501 a(n) = smallest prime greater than a(n-1) and beginning with n.

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, 2111, 2203, 2309, 2411, 2503, 2609, 2707, 2801, 2903, 3001, 3109, 3203, 3301, 3407, 3511, 3607, 3701, 3803, 3907, 4001, 4111, 4201, 4327, 4409, 4507, 4603, 4703
Offset: 1

Views

Author

Amarnath Murthy, Nov 08 2002

Keywords

Comments

First 20 terms are the same as that of A030665.

Crossrefs

Cf. A030665.

Programs

  • Mathematica
    a = {}; Do[AppendTo[a, Function[d, FromDigits@ SelectFirst[ IntegerDigits@ Prime@ Range[PrimePi@ Max@ a + 1, 10^4], And[Length@ # >= Length@ d, Take[#, Length@ d] == d] &]][IntegerDigits@ n]], {n, 47}]; a (* Michael De Vlieger, May 24 2016, Version 10 *)

Extensions

Corrected and extended by Ray Chandler, Aug 11 2003

A256481 Smallest prime obtained by appending a number with identical digits to n or 0 if no such prime exists.

Original entry on oeis.org

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

Views

Author

Chai Wah Wu, Mar 31 2015

Keywords

Comments

For n <= 15392, a(n) = 0 if and only if n = 6930. Conjecture: if a(n) = 0, then n is divisible by 3. Conjecture verified for n <= 10^6. a(n) = 0 for n = 6930, 50358, 56574, 72975.

Crossrefs

Programs

  • Python
    from gmpy2 import mpz, digits, is_prime
    def A256481(n,limit=2000):
        if n in (6930,50358,56574,72975):
            return 0
        if n == 0:
            return 2
        sn = str(n)
        for i in range(1,limit+1):
            for j in range(1,10,2):
                si = digits(j,10)*i
                p = mpz(sn+si)
                if is_prime(p):
                    return int(p)
        else:
            return 'search limit reached.'

A258337 Smallest prime starting with n that does not appear earlier.

Original entry on oeis.org

11, 2, 3, 41, 5, 61, 7, 83, 97, 101, 113, 127, 13, 149, 151, 163, 17, 181, 19, 2003, 211, 223, 23, 241, 251, 263, 271, 281, 29, 307, 31, 3203, 331, 347, 353, 367, 37, 383, 397, 401, 419, 421, 43, 443, 457, 461, 47, 487, 491, 503, 5101, 521, 53, 541, 557, 563, 571, 587, 59, 601, 613, 6203, 631, 641, 653, 661, 67, 683, 691, 701
Offset: 1

Views

Author

Vladimir Shevelev, May 27 2015

Keywords

Comments

According to a comment in A018800, every term exists. So the sequence is a permutation of the primes. Indeed, every prime p appears in the sequence either as the p-th term or earlier.

Crossrefs

Programs

  • Haskell
    import Data.List (isPrefixOf, delete)
    a258337 n = a258337_list !! (n-1)
    a258337_list = f 1 $ map show a000040_list where
       f x pss = g pss where
         g (qs:qss) = if show x `isPrefixOf` qs
                         then (read qs :: Int) : f (x + 1) (delete qs pss)
                         else g qss
    -- Reinhard Zumkeller, Jul 01 2015
  • Maple
    N:= 100: # to get a(1) to a(N)
    for n from 1 to N do
      p:= n;
      if n < 10 then
        p1:= 0
      else
        p1:= A[floor(n/10)];
      fi;
      if isprime(p) and p > p1 then
         A[n]:= p
      else
        for d from 1 while not assigned(A[n]) do
          for i from 1 to 10^d-1 do
            p:= 10^d*n+i;
            if p > p1 and isprime(p) then
               A[n]:= p;
               break
            fi;
          od
        od
      fi
    od:
    seq(A[i],i=1..N); # Robert Israel, Jun 29 2015
  • PARI
    sw(m,n)=d1=digits(n);d2=digits(m);for(i=1,min(#d1,#d2),if(d1[i]!=d2[i],return(0)));1
    v=[];n=1;while(n<70,k=1;while(k<10^3,p=prime(k);if(sw(p,n)&&!vecsearch(vecsort(v),p),v=concat(v,p);k=0;n++);k++));v \\ Derek Orr, Jun 13 2015
    

Formula

For n>=2, a(n) >= prime(n-1). The equality holds iff prime(n-1) did not already appear as a(k), k

A030675 Smallest nontrivial extension of n-th palindrome which is a prime.

Original entry on oeis.org

11, 23, 31, 41, 53, 61, 71, 83, 97, 113, 223, 331, 443, 557, 661, 773, 881, 991, 1013, 1117, 1213, 1319, 14107, 1511, 1613, 17107, 1811, 1913, 2027, 2129, 2221, 23201, 2423, 2521, 2621, 2729, 28201, 2927, 3037, 3137, 32303, 3331, 3433
Offset: 1

Keywords

Crossrefs

Programs

  • Maple
    lpe:= proc(n) local b,d,x;
      for d from 1 do
        b:= 10^d*n;
        for x from b+1 to b+10^d-1 by 2 do
          if isprime(x) then return x fi
        od
      od
    end proc:
    digrev:= proc(n) local L,i;
      L:= convert(n,base,10);
      add(L[-i]*10^(i-1),i=1..nops(L))
    end proc:
    N:= 4: # to use all palindromes of up to N digits
    Res:= seq(lpe(n),n=1..9):
    for d from 2 to N do
      if d::even then
        m:= d/2;
        Res:= Res, seq(lpe(n*10^m + digrev(n)), n=10^(m-1)..10^m-1);
      else
        m:= (d-1)/2;
        Res:= Res, seq(seq(lpe(n*10^(m+1)+y*10^m+digrev(n)), y=0..9), n=10^(m-1)..10^m-1);
      fi
    od:
    Res; # Robert Israel, Sep 18 2018
  • Mathematica
    d[n_]:=IntegerDigits[n]; Table[i=1; While[!PrimeQ[x=FromDigits[Flatten[{d[n],d[i]}]]],i=i+2]; x, {n,Select[Range[350],Reverse[x=d[#]]==x &]}]  (* Jayanta Basu, May 24 2013 *)

Formula

a(n) = A030665(A002113(n+1)). - Robert Israel, Sep 18 2018

Extensions

Corrected by Robert Israel, Sep 18 2018

A064792 Append more digits to the n-th prime (leading zeros are permitted) until another prime is reached.

Original entry on oeis.org

23, 31, 53, 71, 113, 131, 173, 191, 233, 293, 311, 373, 419, 431, 479, 5303, 593, 613, 673, 719, 733, 797, 839, 8923, 971, 1013, 1031, 10709, 1091, 11311, 1277, 1319, 1373, 1399, 1493, 1511, 1571, 1637, 16703, 1733, 17903, 1811, 1913, 1931, 1973
Offset: 1

Author

Reinhard Zumkeller, Oct 17 2001

Keywords

Comments

Differs from A030670 in that here the appended digits may start with 0 which is not possible there (although zeros are allowed there, too, if they are not the first appended digit): The first difference appears at a(16) = 5303 where A030670(16) = 5323. - M. F. Hasler, Jan 15 2025

Crossrefs

Cf. A030665.
See A030670 for another version. Note that A030670 >= a(n). Cf. A065112.

Programs

  • PARI
    apply( {A064792(n)=n=prime(n);for(L=1,oo, n*=10; forstep(s=1,10^L-1,2, isprime(n+s)&& return(n+s)))}, [1..44]) \\ M. F. Hasler, Jan 15 2025

Formula

a(n) = A030665(prime(n)). - Michel Marcus, Jan 17 2025

A065145 Smallest prime that begins with the n-th square in decimal notation.

Original entry on oeis.org

11, 41, 97, 163, 251, 367, 491, 641, 811, 1009, 1213, 1447, 1693, 19603, 2251, 25601, 2897, 32401, 3613, 4001, 44101, 48407, 5297, 57601, 6257, 6761, 7297, 7841, 8419, 9001, 9613, 10243, 10891, 115601, 12251, 12967, 13691, 14447, 15217, 16001
Offset: 1

Author

Reinhard Zumkeller, Oct 17 2001

Keywords

Crossrefs

Programs

  • Maple
    f:= proc(n) local d,m,r;
      for d from 1 do
       for m from 1 to 10^d-1 by 2 do
        r:= 10^d*n^2 + m;
        if isprime(r) then return r fi
      od od
    end proc:
    map(f, [$1..100]); # Robert Israel, May 16 2018

Formula

a(n) = A030665(n^2). - Robert Israel, May 16 2018

A308438 a(n) is the smallest prime p whose decimal expansion begins with n and is such that the next prime is p+2n, or -1 if no such prime exists.

Original entry on oeis.org

11, 223, 31, 401, 547, 619, 773, 8581, 9109, 10223, 1129, 12073, 130553, 14563, 150011, 161471, 17257, 18803, 191189, 20809, 210557, 225383, 237091, 240209, 2509433, 2613397, 277429, 283211, 2901649, 308153, 313409, 3204139, 3300613, 3419063, 3507739, 360091, 3727313, 3806347, 3930061, 4045421, 41018911
Offset: 1

Author

J. M. Bergot and Robert Israel, May 30 2019

Keywords

Examples

			For n = 5, 547 is a prime starting with 5, and the next prime after 547 is 557 = 547 + 2*5.  Since this is the least number with these properties, a(5) = 547.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local d,p,q;
      for d from 0 do
        p:= nextprime(n*10^d-1);
        do
          q:= nextprime(p);
          if q - p = 2*n then return p fi;
          if q >= (n+1)*10^d then break fi;
          p:= q;
        od;
      od;
    end proc:
    map(f, [$1..50]);
  • Python
    from sympy import nextprime
    def A308438(n):
        l, p = 1, nextprime(n)
        while True:
            q = nextprime(p)
            if q-p == 2*n:
                return p
            p = q
            if p >= (n+1)*l:
                l *= 10
                p = nextprime(n*l) # Chai Wah Wu, May 31 2019

A346979 Count of the prime decimal descendants of n.

Original entry on oeis.org

83, 63, 23, 22, 23, 11, 29, 23, 3, 4, 54, 1, 9, 14, 6, 7, 3, 4, 7, 40, 0, 4, 19, 15, 8, 7, 10, 14, 5, 6, 2, 7, 0, 16, 9, 11, 12, 13, 4, 1, 34, 1, 8, 14, 5, 1, 13, 5, 5, 16, 6, 0, 9, 0, 24, 4, 6, 19, 2, 9, 25, 16, 0, 7, 4, 4, 3, 11, 2, 7, 7, 4, 1, 15, 2, 8, 8
Offset: 0

Author

Ya-Ping Lu, Aug 09 2021

Keywords

Comments

The number of direct decimal descendants (i.e., decimal children) of n is A038800(n). The number of prime decimal descendants of the n-th prime is A214342(p_n). a(n) is the number of prime decimal descendants of n, which include the prime decimal children of n, the prime decimal children of the prime decimal children of n, and so on.
a(0) = Sum_{m=1..4} (A214342(m) + 1); a(1) = Sum_{m=5..8} (A214342(m) + 1).
a(A032352(m)) = 0; a(A119289(m)) = 0.
A214342 is a subset, as A214342(m) = a(prime(m)).
Conjecture 1: a(n) <= 83. Conjecture 2: lim_{n->oo} (n0/n) = 1, where n0 is the number of zero terms, a(k) = 0, for k <= n.

Examples

			a(4) = 23. The 23 prime decimal descendants of 4 are shown in the tree below.
       _____ 4__________________________
      /      |                          \
     41   ___43______________            47
    /    /   |               \             \
  419  431  433               439          479
            / \              /   \        /   \
        4337  4339         4391  4397   4793  4799
             /  |  \        |     |     /  \
        43391 43397 43399 43913 43973 47933 47939
                            |
                         439133
                            |
                        4391339
		

Programs

  • Mathematica
    Table[Length@Rest@Flatten[FixedPointList[(b=#;Select[Flatten[(a=#;FromDigits/@(Join[IntegerDigits@a,{#}]&/@If[b=={0},Range@9,{1,3,7,9}]))&/@b],PrimeQ])&,{n}]],{n,0,76}] (* Giorgos Kalogeropoulos, Aug 16 2021 *)
  • Python
    from sympy import isprime
    def p_count(k):
        global ct; d = [2, 3, 5, 7] if k == 0 else [1, 3, 7, 9]
        for i in range(4):
            m = 10*k + d[i]
            if isprime(m): ct += 1; p_count(m)
        return ct
    for n in range(100):
        ct = 0; print(p_count(n))
Showing 1-10 of 10 results.