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

A305352 Deletable primes (A080608) under the stricter rule that leading zeros are disallowed.

Original entry on oeis.org

2, 3, 5, 7, 13, 17, 23, 29, 31, 37, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97, 103, 107, 113, 127, 131, 137, 139, 157, 163, 167, 173, 179, 193, 197, 223, 229, 233, 239, 263, 269, 271, 283, 293, 307, 311, 313, 317, 331, 337, 347, 353, 359, 367, 373, 379, 383, 397, 431, 433, 439
Offset: 1

Views

Author

Jeppe Stig Nielsen, Aug 01 2018

Keywords

Comments

Subset of A080608. Numbers 2003, 2017, 2053, 3023, ... are in A080608 but not here.
If you start from a one-digit prime, you can try to build larger and larger deletable primes by inserting digits. If at one point you get stuck and cannot enlarge the number, you have reached a non-insertable prime (A125001). - Jeppe Stig Nielsen, Mar 28 2021

Examples

			2003 is not a member since removing a digit will either give 003 which has a leading zero, or give one of the numbers 203 or 200 which are both composite. However, 2003 is in A080608 because all of 2003, 003, 03, 3 are prime.
		

Crossrefs

Programs

  • Mathematica
    Rest@ Union@ Nest[Function[{a, p}, Append[a, With[{w = IntegerDigits[p]}, If[# == True, p, 0] &@ AnyTrue[Array[If[First@ # == 0, 1, FromDigits@ #] &@ Delete[w, #] &, Length@ w], ! FreeQ[a, #] &]]]] @@ {#, Prime[Length@ # + 1]} &, Prime@ Range@ PrimePi@ 10, 81] (* Michael De Vlieger, Aug 02 2018 *)
  • PARI
    is(n) = !ispseudoprime(n)&&return(0);my(d=digits(n));#d==1&&return(1);for(i=1,#d,my(v=vecextract(d,Str("^"i)));v[1]!=0&&is(fromdigits(v))&&return(1));0
    
  • Python
    from sympy import isprime
    def ok(n):
        if not isprime(n): return False
        if n < 10: return True
        s = str(n)
        si = (s[:i]+s[i+1:] for i in range(len(s)))
        return any(t[0] != '0' and ok(int(t)) for t in si)
    print([k for k in range(440) if ok(k)]) # Michael S. Branicky, Jan 28 2023

A356557 Start with a(1)=2; to get a(n+1) insert in a(n) at the rightmost possible position the smallest possible digit such that the new number is a prime.

Original entry on oeis.org

2, 23, 233, 2333, 23333, 233323, 2333231, 23332301, 233323001, 2333230019, 23332030019, 233320360019, 2333203600159, 23332036001959, 233320360019569, 2333203600195669, 23332036001956469, 233320360019564269, 2333203600195642469, 23332036001956424629, 233320360019564246269
Offset: 1

Views

Author

Bartlomiej Pawlik, Aug 12 2022

Keywords

Comments

Extending a number by inserting a prepending "0" is obviously not allowed. Rightmostness of position has precedence over smallness of digit. If no prime extension exists, the sequence terminates.
Sequence inspired by A332603.
Sequence construction very similar to A357436 (the difference arises from the order of the conditions).
Length of a(n) is n.
Is the sequence infinite? The analogous sequences using bases 2, 3, 4, 5 and 7 are finite.
Sequence terminates if and only if it contains a term of A125001.

Examples

			a(2) = 23 because the numbers 20, 21, 22 obtained from a(1) = 2 are composite and 23 is a prime.
For n=6, starting from a(5)=23333 and appending a new rightmost digit gives 233330, 233331, ..., 233339 which are not primes. Inserting a digit second-rightmost gives 233303 and 233313 which are also not prime, and 233323 which is prime, so a(6) = 233323.
		

Crossrefs

Programs

  • Mathematica
    k = 2; K = {k}; For[n = 1, n <= 20, n++, r = 0; For[p = IntegerLength[k] + 1, p >= 1, p--, If[r == 1, Break[]]; For[d = 0, d <= 9, d++, If[PrimeQ[ m = ToExpression[StringInsert[ToString[k], ToString[d], p]]], If[k != m, k = m, Print["FINITE"]]; AppendTo[K, k]; r = 1; Break[]]]]]; Print[K] (* Samuel Harkness, Sep 29 2022 *)
  • Python
    from sympy import isprime
    from itertools import islice
    def anext(an):
        s = str(an)
        for k in range(len(s)+1):
            for c in "0123456789":
                w = s + c if k == 0 else s[:-k] + c + s[-k:]
                if isprime(int(w)): return int(w)
    def agen(an=2):
        while an != None: yield an; an = anext(an)
    print(list(islice(agen(), 21))) # Michael S. Branicky, Aug 12 2022

A357436 Start with a(1)=2; to get a(n+1) insert in a(n) the smallest possible digit at the rightmost possible position such that the new number is a prime.

Original entry on oeis.org

2, 23, 223, 2203, 22003, 220013, 2200103, 22000103, 223000103, 2230001003, 22300010023, 223000100023, 2230001000203, 22301001000203, 223010001000203, 2230010001000203, 22300010001000203, 222300010001000203, 2223000100010001203, 22203000100010001203, 222030001000010001203, 2220300010200010001203
Offset: 1

Views

Author

Bartlomiej Pawlik, Sep 28 2022

Keywords

Comments

Extending a number by inserting a prepending "0" is obviously not allowed. Smallness of digit has precedence over rightmostness of position. If no prime extension exists, the sequence terminates.
Sequence construction very similar to A356557 (the difference arises from the order of the conditions).
Length of a(n) is n.
Is the sequence infinite?
Sequence terminates if and only if it contains a term of A125001.

Examples

			a(2) = 23 because the numbers 20, 21, 12, 22 obtained from a(1) = 2 are composite and 23 is a prime.
For n=6, starting from a(5)=22003 and appending a digit "0" from right to left gives 220030, 220003, 202003, which are not primes. Inserting a digit "1" from right to left gives 220031 which also is not prime, and 220013 which is prime, so a(6) = 220013.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local x, y,z, j;
          for x from 0 to 9 do
            for j from 0 to length(n)-`if`(x=0,1,0) do
               y:= n mod 10^j;
               z:= y + x*10^j + 10*(n-y);
               if isprime(z) then return z fi;
          od od;
          FAIL
    end proc:
    R:= 2: x:= 2:
    for count from 2 to 30 while x <> FAIL do
        x:= f(x); R:= R, x;
    od:
    R; # Robert Israel, Sep 29 2022
  • Mathematica
    a[1]=2; a[n_] := a[n] = Catch@ Block[{p, d = IntegerDigits[a[n-1]]}, Do[p = FromDigits@ Insert[d, c, -i]; If[p > a[n - 1] && PrimeQ[p], Throw@p], {c, 0, 9}, {i, 1 + Length@ d}]]; Array[a, 22] (* Giovanni Resta, Oct 13 2022 *)
  • Python
    from sympy import isprime
    from itertools import islice
    def anext(an):
        s = str(an)
        for c in "0123456789":
            for k in range(len(s)+1):
                w = s + c if k == 0 else s[:-k] + c + s[-k:]
                if w[0] != "0" and isprime(int(w)): return int(w)
    def agen(an=2):
        while an != None: yield an; an = anext(an)
    print(list(islice(agen(), 22))) # Michael S. Branicky, Sep 29 2022

Extensions

More terms from Robert Israel, Sep 29 2022
Showing 1-3 of 3 results.