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.

User: Gennady Eremin

Gennady Eremin's wiki page.

Gennady Eremin has authored 7 sequences.

A350577 Prime numbers in A036991.

Original entry on oeis.org

3, 5, 7, 11, 13, 19, 23, 29, 31, 43, 47, 53, 59, 61, 71, 79, 83, 103, 107, 109, 127, 151, 157, 167, 173, 179, 181, 191, 199, 211, 223, 239, 251, 271, 283, 307, 311, 317, 331, 347, 349, 359, 367, 373, 379, 383, 431, 439, 443, 461, 463, 467, 479, 487, 491, 499
Offset: 1

Author

Gennady Eremin, Jan 07 2022

Keywords

Comments

This sequence includes A000668.
Conjecture: The sequence is infinite. For example, in the first million primes (see A000040) 304208 numbers are terms of A036991.

Crossrefs

Programs

  • Maple
    q:= proc(n) local l, t, i; l:= Bits[Split](n); t:=0;
          for i to nops(l) do t:= t-1+2*l[i];
            if t<0 then return false fi
          od: true
        end:
    select(isprime and q, [$2..500])[];  # Alois P. Heinz, Jan 07 2022
  • Mathematica
    q[n_] := PrimeQ[n] && AllTrue[Accumulate[(-1)^Reverse[IntegerDigits[n, 2]]], # <= 0 &]; Select[Range[500], q] (* Amiram Eldar, Jan 07 2022 *)
  • Python
    from sympy import isprime
    def ok(n):
        if n == 0: return True
        count = {"0": 0, "1": 0}
        for bit in bin(n)[:1:-1]:
            count[bit] += 1
            if count["0"] > count["1"]: return False
        return isprime(n)
    print([k for k in range(3, 500, 2) if ok(k)]) # Michael S. Branicky, Jan 07 2022

Formula

Intersection of A000040 and A036991.

A350346 Binary numbers such that when read from right to left, the number of 0's never exceeds the number of 1's.

Original entry on oeis.org

0, 1, 11, 101, 111, 1011, 1101, 1111, 10011, 10101, 10111, 11011, 11101, 11111, 100111, 101011, 101101, 101111, 110011, 110101, 110111, 111011, 111101, 111111, 1000111, 1001011, 1001101, 1001111, 1010011, 1010101, 1010111, 1011011, 1011101, 1011111, 1100111
Offset: 1

Author

Gennady Eremin, Dec 26 2021

Keywords

Comments

Binary expansion of A036991 terms.
Dyck language interpreted as binary numbers in ascending order (inverse encode of A063171).
The first term a(1)=0 corresponds to an empty string, denote it NULL.
Restoring the leading 0's (need the same number of 0's and 1's) and then replacing "0" by the left parenthesis "(" and "1" by the right parenthesis ")" give well-formed parenthesis strings: 0 -> NULL, 1=01 -> (), 11=0011 -> (()), 101=0101 -> ()(), 111=000111 -> ((())), 1011=001011 -> (()()), 1101=001101 -> (())() and so on.
Chomsky-2 grammar with axiom s, terminal alphabet {0, 1} and three rules s -> ss, s -> 0s1, s -> 01 (compare A063171).

Examples

			s -> ss -> 0s1s -> 00s11s -> 000111s -> 00011101 = 11101.
		

Crossrefs

Programs

  • Mathematica
    Join[{0},Select[Table[FromDigits[IntegerDigits[n,2]],{n,120}],Min[Accumulate[ Reverse[ IntegerDigits[#]]/.(0->-1)]]>=0&]] (* Harvey P. Dale, Apr 29 2022 *)
  • Python
    def ok(n):
        if n == 0: return True
        count = {"0": 0, "1": 0}
        for bit in bin(n)[:1:-1]:
            count[bit] += 1
            if count["0"] > count["1"]: return False
        return True # A036991
    nn = 1; print(1, 0)
    for n in range(1, 23230):  # printing b-file
        if ok(n) == False: continue
        nn += 1; print(nn, bin(n)[2:])
    
  • Python
    from itertools import count, islice
    def A350346_gen(): # generator of terms
        yield 0
        for n in count(1):
            s = bin(n)[2:]
            c, l = 0, len(s)
            for i in range(l):
                c += int(s[l-i-1])
                if 2*c <= i:
                    break
            else:
                yield int(s)
    A350346_list = list(islice(A350346_gen(),20)) # Chai Wah Wu, Dec 30 2021

Formula

a(n) = A007088(A036991(n)). - Michel Marcus, Dec 26 2021

A343773 Excess of the number of even Motzkin n-paths (A107587) over the odd ones (A343386).

Original entry on oeis.org

1, 1, 0, -2, -3, 1, 11, 15, -13, -77, -86, 144, 595, 495, -1520, -4810, -2485, 15675, 39560, 6290, -159105, -324805, 87075, 1592843, 2616757, -2136539, -15726114, -20247800, 32296693, 152909577, 145139491, -417959049, -1460704685, -885536173, 4997618808, 13658704994
Offset: 0

Author

Keywords

Comments

All terms a(n), n >= 0, are contained in both A100223 and A214649, as well as in A007440 (if the signs of integers are not taken into account). So these sequences form a cluster, the base of which is the current sequence.
The Motzkin number A001006(n) is split into two parts A107587(n) and A343386(n) (see A343386). The value a(n), the difference between A107587(n) and A343386(n), can be called the "shadow" of A001006(n). This is clearly seen if we compare the g.f. for the Motzkin numbers M(x) = 1 + x*M(x) + x^2*M(x)^2 and the current g.f. A(x) = 1 + x*A(x) - x^2*A(x)^2.
Binomial transform of 1, 0, -1, 0, 2, 0, -5, 0, 14, 0, -42, 0, ... (see A000108). - Gennady Eremin, Jul 14 2021

Examples

			G.f. = 1 + x - 2*x^3 - 3*x^4 + x^5 + 11*x^6 + 15*x^7 - 13*x^8 - 77*x^9 - 86*x^10 + 144*x^11 + ...
		

Programs

  • Mathematica
    With[{$MaxExtraPrecision = 1000}, CoefficientList[Series[(-1 + x + Sqrt[1 - 2 x + 5 x^2])/(2 x^2), {x, 0, 36}], x] ] (* Michael De Vlieger, May 01 2021 *)
    a[n_] := Hypergeometric2F1[(1 - n)/2, -n/2, 2, -4];
    Table[a[n], {n, 0, 35}] (* Peter Luschny, May 30 2021 *)
    a[ n_] := If[n<0, 0, SeriesCoefficient[Nest[1 + x*# - (x*#)^2&, 1 + O[x], n], {x, 0, n}]]; (* Michael Somos, Oct 27 2024 *)
    a[ n_] := SeriesCoefficient[2/(1 - x + (1 - 2*x + 5*x^2)^(1/2)), {x, 0, n}]; (* Michael Somos, Oct 27 2024 *)
  • PARI
    {a(n) = my(y = 1 + O(x)); for(i = 1, n, y = 1 + x*y - x^2*y^2); polcoeff(y, n)}; /* Michael Somos, Oct 27 2024 */
    
  • PARI
    {a(n) = polcoeff( 2/(1 - x + (1 - 2*x + 5*x^2 + x*O(x^n))^(1/2)), n)}; /* Michael Somos, Oct 27 2024 */
  • Python
    A343773 = [1, 1]
    for n in range(2, 801):
        A343773.append(((2*n+1)*A343773[-1]
          - 5*(n-1)*A343773[-2]) // (n+2))
    

Formula

a(n) = A107587(n) - A343386(n), n>=0.
a(n) = A100223(n+2) = A214649(n+1), n>=0.
a(n) = (-1)^n * A007440(n+1), n>=0.
D-finite with recurrence a(n) = ((2*n+1)*a(n-1) - 5*(n-1)*a(n-2))/(n+2), n>1.
G.f.: (-1 + x + sqrt(1 - 2*x + 5*x^2))/(2*x^2).
G.f. A(x) satisfies A(x) = 1 + x*A(x) - x^2*A(x)^2.
a(n) = Sum_{k=0..floor(n/2)} (-1)^k * binomial(n, 2*k) * A000108(k).
a(n) = 2*A107587(n) - A001006(n) = A001006(n) - 2*A343386(n).
Limit_{n->oo} a(n)/A001006(n) = 0.
a(n) = hypergeom([(1 - n)/2, -n/2], [2], -4). - Peter Luschny, May 30 2021
G.f. A(x) with offset 1 is the reversion of g.f. for signed Fibonacci numbers 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, ... (see A039834 starting at offset 1). - Gennady Eremin, Jul 15 2021

A343386 Number of odd Motzkin n-paths, i.e., Motzkin n-paths with an odd number of up steps.

Original entry on oeis.org

0, 0, 1, 3, 6, 10, 20, 56, 168, 456, 1137, 2827, 7458, 20670, 57577, 157691, 427976, 1170552, 3248411, 9096497, 25505562, 71436182, 200338074, 564083786, 1595055520, 4522769520, 12842772295, 36514010301, 103995490758, 296794937626, 848620165860, 2430089817720
Offset: 0

Author

Keywords

Comments

a(n) is the number of Motzkin n-paths with an odd number of U-steps (see A001006). For example, there are 9 Motzkin 4-paths, of which six have one U-step each, namely: 00UD, 0U0D, 0UD0, U00D, U0D0, and UD00. So a(4) = 6.
Number of Motzkin n-paths that, after removing the horizontal steps, are converted to Dyck (2m)-paths, where 2m <= n and m is odd (see A024492).

Examples

			G.f. = x^2 + 3*x^3 + 6*x^4 + 10*x^5 + 20*x^6 + 56*x^7 + 168*x^8 + ...
		

Crossrefs

Programs

  • Mathematica
    a[n_] := ((n - 1) n HypergeometricPFQ[{1/2 - n/4, 3/4 - n/4, 1 - n/4, 5/4 - n/4}, {3/2, 3/2, 2}, 16])/2;
    Table[a[n], {n, 0, 31}] (* Peter Luschny, Sep 24 2021 *)
  • Python
    M = [4, 9]; E = [1, 1, 1, 1, 3];
    A343386 = [0, 0, 1, 3, 6]
    for n in range(5, 801):
        M.append(((2*n+1)*M[1]+(3*n-3)*M[0])//(n+2))
        E.append(((5*n**2+n-3)*E[4] - (10*n**2-16*n+3)*E[3]
          + (10*n**2-34*n+27)*E[2] + (11*n-5)*(n-3)*E[1]
          - 15*(n-3)*(n-4)*E[0]) // (n*n+2*n))
        A343386.append(M[-1] - E[-1])
        M.pop(0); E.pop(0)

Formula

a(n) = Sum_{k=0..n} binomial(n, 4*k+2) * A000108(2*k+1).
a(n) = A001006(n) - A107587(n).
G.f.: A(x) = (2 - 2*x - sqrt(1-2*x-3*x^2) - sqrt(1-2*x+5*x^2))/(4*x^2).
G.f. A(x) satisfies A(x) = x*A(x) + x^2*A(x)^2 + x^2*B(x)^2 where B(x) is the g.f. of A107587.
a(n) = A107587(n) - A100223(n+2). - R. J. Mathar, Apr 16 2021
D-finite with recurrence: n*(n+2)*a(n) + (-5*n^2-n+3)*a(n-1) + (10*n^2-16*n+3)*a(n-2) + (-10*n^2+34*n-27)*a(n-3) - (11*n-5)*(n-3)*a(n-4) + 15*(n-3)*(n-4)*a(n-5) = 0, n >= 5. - R. J. Mathar, Apr 17 2021
D-finite with recurrence: n*(n-2)*(n+2)*a(n) - (2*n-1)*(2*n^2-2*n-3)*a(n-1) + 3*(n-1)*(2*n^2-4*n+1)*a(n-2) - 2*(n-1)*(n-2)*(2*n-3)*a(n-3) - 15*(n-1)*(n-2)*(n-3)*a(n-4) = 0, n >= 4. - R. J. Mathar, Apr 17 2021
a(n) = Sum_{k=0..floor(n/2)} binomial(n, 2*k) * A000108(k) * (k mod 2). - Gennady Eremin, May 03 2021 [after Paul Barry (A107587)]
a(n) = ((n-1)*n*hypergeom([1/2-n/4, 3/4-n/4, 1-n/4, 5/4-n/4], [3/2, 3/2, 2], 16))/2. - Peter Luschny, Sep 24 2021
a(n) ~ 3^(n + 3/2) / (4*sqrt(Pi)*n^(3/2)). - Vaclav Kotesovec, Apr 27 2024

A340544 Numbers from A340131 that are not multiples of 3.

Original entry on oeis.org

5, 11, 29, 44, 50, 83, 98, 104, 116, 128, 140, 146, 245, 260, 266, 278, 290, 302, 308, 332, 344, 377, 380, 395, 401, 410, 416, 434, 449, 455, 731, 746, 752, 764, 776, 788, 794, 818, 830, 863, 866, 881, 887, 896, 902, 920, 935, 941, 980, 992, 1025, 1028, 1043
Offset: 1

Author

Gennady Eremin, Jan 11 2021

Keywords

Comments

Terms are reduced, i.e., ternary codes do not have trailing zeros.
The term is a digitized Motzkin path that starts with an up step and ends with a down step. Such a path has neither leading nor final flat steps, i.e., the ternary code of the corresponding term has no finite 0's. Recall that in ternary code, 1's are up steps, and 2's are down steps.
The number of terms with a ternary code of length k is A026107(k-1). For instance, 7 (seven) reduced terms 83, 98, 104, 116, 128, 140, and 146 have a ternary length of 5, namely 10002, 10122, 10212, 11022, 11202, 12012, and 12102. Respectively A026107(4) = 7.

Crossrefs

Intersection of A001651 and A340131.
Subsequences: A134752, A168607.
Cf. A026107.

Programs

  • Python
    def digits(n, b):
      out = []
      while n >= b:
        out.append(n % b)
        n //= b
      return [n] + out[::-1]
    def ok(n):
      if n%3 == 0: return False
      t = digits(n, 3)
      if t.count(1) != t.count(2): return False
      return all(t[:i].count(1) >= t[:i].count(2) for i in range(1, len(t)))
    print([n for n in range(750) if ok(n)]) # after Michael S. Branicky (A340131)

A340395 a(n) = A340131(A001006(n)).

Original entry on oeis.org

5, 15, 50, 150, 455, 1365, 4100, 12300, 36905, 110715, 332150, 996450, 2989355, 8968065, 26904200, 80712600, 242137805, 726413415, 2179240250, 6537720750, 19613162255, 58839486765, 176518460300, 529555380900, 1588666142705, 4765998428115, 14297995284350
Offset: 2

Author

Gennady Eremin, Jan 06 2021

Keywords

Comments

This sequence is associated with A340131, whose terms are sorted by the length of their ternary code. Elements with the same length of ternary code form a range that has a maximum. The maximal term of the n-range (a set of elements with ternary code length n in A340131) is a(n). Example: numbers 29, 33, 44, 45 and 50 have a ternary length of 4 (see A340131), respectively a(4) = 50.
Ternary code for a(n) is 12..12 for even n and 12..120 for odd n.

Examples

			A001006(2) = 2, so a(2) = A340131(2) = 5.
A001006(3) = 4, so a(3) = A340131(4) = 15, etc.
		

Crossrefs

Subsequence of A340131.

Programs

  • PARI
    Vec(5/(1 - 3*x - x^2 + 3*x^3) + O(x^30)) \\ Andrew Howroyd, Jan 08 2021

Formula

a(n) = 5*3^(n-2*k)*(9^k-1)/8 where k = floor(n/2).
a(n+1) = 3*a(n) for even n >= 2; a(n+1) = 3*a(n)+5 for odd n >= 3.
a(n) = 5*A033113(n-1).
a(n) = (5/8)*(3^n - (-1)^(n-1) - 2).
a(n) = 2*a(n-1) + 3*a(n-2) + 5 for n > 3.
From Stefano Spezia, Jan 06 2021: (Start)
G.f.: 5*x^2/(1 - 3*x - x^2 + 3*x^3).
a(n) = 3*a(n-1) + a(n-2) - 3*a(n-3) for n > 4. (End)

A340131 Numbers whose ternary expansions have the same number of 1's and 2's and, in each prefix (initial fragment), at least as many 1's as 2's.

Original entry on oeis.org

0, 5, 11, 15, 29, 33, 44, 45, 50, 83, 87, 98, 99, 104, 116, 128, 132, 135, 140, 146, 150, 245, 249, 260, 261, 266, 278, 290, 294, 297, 302, 308, 312, 332, 344, 348, 377, 380, 384, 395, 396, 401, 405, 410, 416, 420, 434, 438, 449, 450, 455, 731, 735, 746, 747
Offset: 1

Author

Gennady Eremin, Dec 29 2020

Keywords

Comments

For a nonzero term, the ternary code starts with 1, otherwise the balance of 1's and 2's is broken already in the one-digit prefix. Therefore 7, 19, 21, etc. (see A039001) are not terms.
As another example, for the integer 52 the balance is broken in the three-digit prefix 122 (the entire ternary code is 1221).
Each term with a ternary code of length k corresponds one-to-one to the Motzkin path of length k that starts with an up step. Therefore, the terms can be called digitized Motzkin paths.
The number of terms with a ternary code of length k is equal to A244884(k). Example: five terms 29, 33, 44, 45 and 50 have a ternary length of 4, respectively A244884(4)=5.

Examples

			The first terms 0 and 5 are obvious, because the four intermediate ternary codes 1, 2, 10[3], and 11[4] are rejected due to a violation of the balance of 1's and 2's. Next, the successor function S works: for any term x, the next term is S(x).
Iterating over numbers is inefficient; code suffixes (final digits) can be processed faster. The transition from 0 to 12[5] is generalized for terms that are multiples of 9. For example,
S(10200[99]) = 10212[104], S(1122000[1188]) = 1122012[1193], etc.
In this case, the calculation of the subsequent term is reduced to simply replacing the suffix s = 00 with the subsequent suffix s'= 12.
Another common suffix is s = 02..2 = 02^k (twos are repeated at the end of the ternary code). Then the subsequent suffix is s'= 202..2 = 202^(k-1), i.e., within such a suffix, the first two digits are reversed. Here are some examples:
k = 1, S(1002[29]) = 1020[33], the increment is 4*3^0 = 4;
k = 2, S(110022[332]) = 110202[344], the increment is 4*3^1 = 12;
k = 3, S(10110222[2537]) = 10112022[2573], the increment is 4*3^2 = 36;
k = 4, S(111102222[9800]) = 111120222[9908], the increment is 4*3^3 = 108.
There are 5 such group suffixes.
		

Crossrefs

Subsequence of A039001.
Subsequences: A134752, A168607.
Cf. A244884.

Programs

  • PARI
    is(n) = {my(d = digits(n, 3), v = [0, 0]); for(i = 1, #d, if(d[i] > 0, v[d[i]]++); if(v[1] < v[2], return(0))); v[1] == v[2] } \\ David A. Corneth, Dec 29 2020
    
  • Python
    def digits(n, b):
      out = []
      while n >= b:
        out.append(n % b)
        n //= b
      return [n] + out[::-1]
    def ok(n):
      t = digits(n, 3)
      if t.count(1) != t.count(2): return False
      return all(t[:i].count(1) >= t[:i].count(2) for i in range(1, len(t)))
    print([n for n in range(750) if ok(n)]) # Michael S. Branicky, Dec 29 2020