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.

A125001 Non-insertable primes: primes with property that no matter where you insert (or prepend or append) a digit you get a composite number (except for prepending a zero).

Original entry on oeis.org

369293, 3823867, 5364431, 5409259, 7904521, 8309369, 9387527, 9510341, 22038829, 27195601, 28653263, 38696543, 39091441, 39113161, 43744697, 45095839, 45937109, 48296921, 48694231, 49085093, 49106677, 50791927
Offset: 1

Views

Author

David W. Wilson, Jan 08 2007

Keywords

Comments

Is the sequence infinite? - Zak Seidov, Nov 14 2014

Examples

			369293 is a member because all of 1369293, 2369293, 3369293, ..., 3069293, 3169293, ..., 3692930, ..., 3692939 are composite.
		

Crossrefs

Programs

  • Mathematica
    nipQ[x_]:=Module[{id=IntegerDigits[x],len},len=Length[id];AllTrue[ Select[ Flatten[Table[FromDigits[Insert[id,n,i]],{i,len+1},{n,0,9}],1],#!=x&], CompositeQ]]; Select[ Prime[Range[3050000]],nipQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Apr 12 2018 *)
  • Python
    from sympy import isprime
    from itertools import islice
    def ok(n):
        if not isprime(n): return False
        s = str(n)
        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 False
        return True
    print([k for k in range(10**7) if ok(k)]) # Michael S. Branicky, Sep 29 2022

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