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

A332604 Limiting word over the alphabet {1,2,3} defined by the process in A332603, or, in case that process terminates, the final term in A332603.

Original entry on oeis.org

1, 2, 1, 3, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 2, 1, 3, 1, 2, 3, 1, 3, 2, 3, 1, 2, 1, 3, 1, 2, 3, 2, 1, 2, 3, 1, 2, 1, 3, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 2, 1, 3, 1, 2, 3, 2, 1, 2, 3, 1, 2, 1, 3, 2, 1, 2, 3, 1, 3, 2, 3, 1, 2, 1, 3, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 2, 1, 3
Offset: 1

Views

Author

N. J. A. Sloane, Mar 07 2020

Keywords

Comments

Grytczuk et al. (2020) conjecture that the process in A332603 never terminates, and report that they have computed the first 5000 terms of the limiting word.

Crossrefs

Cf. A332603.

Programs

  • Mathematica
    sqfQ[str_] := StringFreeQ[str, x__ ~~ x__]; ext[s_] := Catch@ Block[{t}, Do[ If[sqfQ[t = StringInsert[s, e, -p]], Throw@ t], {p, StringLength[s] + 1}, {e, {"1", "2", "3"} } ]]; a[1]=1; a[n_] := a[n] = ToExpression@ ext@ ToString@ a[n-1]; IntegerDigits@ a[88] (* Giovanni Resta, Mar 09 2020 *)

Extensions

More terms from Giovanni Resta, Mar 09 2020

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

A351386 Sequence of balanced, multiplicative binary words, starting with a(1)=1, a(2)=10; for j > 2, if j is a prime, then a(j) is obtained by appending 0 at the end of a(j-1); otherwise, a(j) is obtained by appending a single digit at the end of a(j-1) such that the new word is multiplicative, but if the obtained a(j) is not balanced, then we change the digit at the rightmost possible prime position (and, eventually, some digits at following nonprime positions to maintain multiplicativity) so that a(j) becomes balanced.

Original entry on oeis.org

1, 10, 100, 1001, 10010, 100101, 1001010, 10010110, 100101101, 1001010011, 10010100110, 100101001110, 1001010011100, 10010100111001, 100101001110011, 1001010011000111, 10010100110001110, 100101001100011110, 1001010011000111100, 10010100110001111010, 100101001100011110101
Offset: 1

Views

Author

Bartlomiej Pawlik, Feb 09 2022

Keywords

Comments

A binary word here is balanced if the numbers of 0's and 1's differ by at most one.
A binary word here is multiplicative if for all b,c > 1 if at its b-th position is a digit B and at c-th position is C, then at (b*c)-th position is a digit 1 if b=c and 0 otherwise.
According to Grytczuk (2021), the authorship of the sequence belongs to Krzysztof Rejmer.
Rejmer conjectures that this process never terminates (see Grytczuk (2021)).
Every odd term is automatically balanced (since it follows the even term which has the same number of 0's and 1's).
More naturally can be looked at as a balanced multiplicative sequence of strings of signs - and + (where the multiplication is implied by standard multiplication on integers).
This sequence was the inspiration for creating the sequence A332603 proposed in Grytczuk et al. (2020).

Examples

			a(15) = 100101001110011. To obtain the 16th term we arbitrarily choose a nontrivial decomposition of 16, for example, 2*8. The second (2) digit in a(15) is 0 and the eighth (8) digit is 0, so as the last digit of a(16) we append 1. We obtain a(16) = 1001010011100111, which is not balanced. Changing the 13th digit in a(16) (0 to 1) only decreases balance, so we check the next possible prime: changing the 11th digit (1 to 0) results in a balanced a(16) = 1001010011000111.
It is sufficient to test just one factorization - multiplicativity of the word guarantees that every factorization gives us the same result.
		

Crossrefs

Programs

  • Mathematica
    a = "1";
    list = {a};
    For[j = 2, j <= 100, j++,
    If[PrimeQ[j] == True, a = a <> "0",
      i = 2; While[IntegerQ[j/i] == False, i++];
      a1 = ToExpression[StringTake[a, {i}]];
      a2 = ToExpression[StringTake[a, {j/i}]];
      If[a1 == a2, b = a <> "1", b = a <> "0"];
      If[Abs[StringCount[b, "0"] - StringCount[b, "1"]] < 2, a = b,
       For[k = j - 1, k >= 2, k = k - 1,
        If[PrimeQ[k] == True,
         c = StringTake[b, k - 1] <>
           ToString[1 - ToExpression[StringTake[b, {k}]]] <>
           StringTake[b, -(j - k)];
         For[l = k + 1, l <= j, l++,
          If[PrimeQ[l] == False,
           li = 2; While[IntegerQ[l/li] == False, li++];
           la1 = ToExpression[StringTake[c, {li}]];
           la2 = ToExpression[StringTake[c, {l/li}]];
           If[la1 == la2,
            c = StringTake[c, l - 1] <> "1" <> StringTake[c, -(j - l)],
            c = StringTake[c, l - 1] <> "0" <> StringTake[c, -(j - l)]]
           ]];
         If[Abs[StringCount[c, "0"] - StringCount[c, "1"]] < 2, a = c;
          Break[]]
         ]
        ]; If[b == c, Print["STOP"]; Break[]]
       ]
      ];
    list = Append[list, a]] ; Print[list]
Showing 1-4 of 4 results.