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.

Previous Showing 11-14 of 14 results.

A036994 Numbers k with the property that reading from right to left in the binary expansion of k, the number of 1's always stays ahead of the number of 0's.

Original entry on oeis.org

1, 3, 7, 11, 15, 23, 27, 31, 39, 43, 47, 55, 59, 63, 79, 87, 91, 95, 103, 107, 111, 119, 123, 127, 143, 151, 155, 159, 167, 171, 175, 183, 187, 191, 207, 215, 219, 223, 231, 235, 239, 247, 251, 255, 287, 303, 311, 315, 319, 335, 343, 347, 351, 359, 363, 367
Offset: 1

Views

Author

Keywords

Comments

Even numbers can't appear in this sequence. - Alonso del Arte, Sep 21 2011

Crossrefs

Programs

  • Haskell
    a036994 n = a036994_list !! (n-1)
    a036994_list = filter ((p 0) . a030308_row) [1, 3 ..] where
       p ones []    = ones > 0
       p ones (0:bs) = ones > 1 && p (ones - 1) bs
       p ones (1:bs) = p (ones + 1) bs
    -- Reinhard Zumkeller, Aug 01 2013
    
  • Mathematica
    aheadOnesRLQ[n_Integer] := Module[{digits, len, flag = True, iter = 1, ones = 0, zeros = 0}, digits = Reverse[IntegerDigits[n, 2]]; len = Length[digits]; While[flag && iter < len, If[digits[[iter]] == 1, ones++, zeros++]; flag = ones > zeros; iter++]; flag]; Select[Range[1, 201, 2], aheadOnesRLQ] (* Alonso del Arte, Sep 21 2011 *)
    Select[Range[400],Min[Accumulate[Reverse[IntegerDigits[#,2]/. (0->-1)]]]> 0&] (* Harvey P. Dale, Apr 23 2016 *)
  • PARI
    ok(x)={if(x<1,return(0));my(c=logint(x,2),c0=0,c1=0);for(i=0,c,if(bittest(x,i),c1++,c0++);if(c1<=c0,return(0)));1} \\ for(n=1,367,if(ok(n),print1(n,", "))) - Ruud H.G. van Tol, Sep 14 2022
  • Python
    from itertools import count, islice
    def A036994_gen(startvalue=0): # generator of terms >= startvalue
        for n in count(max(startvalue,0)):
            s = bin(n)[2:]
            c, l = 0, len(s)
            for i in range(l):
                c += int(s[l-i-1])
                if 2*c <= i + 1:
                    break
            else:
                yield n
    A036994_list = list(islice(A036994_gen(),20)) # Chai Wah Wu, Dec 31 2021
    

Extensions

More terms from Erich Friedman

A116385 Expansion of e.g.f. Bessel_I(2,2x) + 2*Bessel_I(3,2x) + Bessel_I(4,2x).

Original entry on oeis.org

0, 0, 1, 2, 5, 10, 21, 42, 84, 168, 330, 660, 1287, 2574, 5005, 10010, 19448, 38896, 75582, 151164, 293930, 587860, 1144066, 2288132, 4457400, 8914800, 17383860, 34767720, 67863915, 135727830, 265182525, 530365050, 1037158320, 2074316640
Offset: 0

Views

Author

Paul Barry, Feb 12 2006

Keywords

Comments

Third column of the Riordan array A116382.
Apart from its root term -1: central terms of the triangle in A051631: a(n) = A051631(n+1, [(n+1)/2]). - Reinhard Zumkeller, Nov 13 2011

Crossrefs

Cf. A001405.

Programs

  • Haskell
    a116385 n = a051631 (n+1) $ (n+1) `div` 2
    -- Reinhard Zumkeller, Nov 13 2011
    
  • Mathematica
    With[{nn=40},CoefficientList[Series[BesselI[2,2x]+2BesselI[3,2x]+ BesselI[ 4,2x],{x,0,nn}],x]Range[0,nn]!] (* Harvey P. Dale, Sep 14 2011 *)
  • PARI
    a(n)= binomial(n+3, (n+3)\2) - 3*binomial(n+1, (n+1)\2) \\ Bill McEachen, Dec 12 2022

Formula

E.g.f.: (d/dx)(Bessel_I(3,2x),x) + 2*Bessel_I(3,2x).
a(n) = C(n+1,floor((n-2)/2))*(1+(-1)^n)/2 + C(n,floor((n-3)/2))*(1-(-1)^n).
Conjecture: (n+4)*a(n) -2*a(n-1) +(-7*n-8)*a(n-2) +6*a(n-3) +12*(n-2)*a(n-4)=0. - R. J. Mathar, Jun 13 2014
a(n) = A001405(n+3) - 3*A001405(n+1) (from Eremin link). - Bill McEachen, Dec 12 2022
G.f.: (-1 - x + x^2 + B(x) - 3*x^2*B(x))/x^3, where B(x) is the g.f. of A001405. - Gennady Eremin, Oct 09 2023

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

Views

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

A114567 a(n) is the number k such that the binary expansion of n mod 2^k is the postorder traversal of a binary tree, where 1 indicates a node and 0 indicates there are no children on that side.

Original entry on oeis.org

1, 3, 1, 5, 1, 5, 1, 7, 1, 3, 1, 7, 1, 7, 1, 9, 1, 3, 1, 7, 1, 7, 1, 9, 1, 3, 1, 9, 1, 9, 1, 11, 1, 3, 1, 5, 1, 5, 1, 9, 1, 3, 1, 9, 1, 9, 1, 11, 1, 3, 1, 9, 1, 9, 1, 11, 1, 3, 1, 11, 1, 11, 1, 13, 1, 3, 1, 5, 1, 5, 1, 9, 1, 3, 1, 9, 1, 9, 1, 11, 1, 3, 1, 9, 1, 9, 1, 11, 1, 3, 1, 11, 1, 11, 1, 13, 1, 3, 1, 5, 1
Offset: 0

Views

Author

Mike Stay, Feb 15 2006

Keywords

Comments

Postorder traversals of a binary tree form an instantaneous code; any integer has a unique decomposition into codewords. To get the first codeword, find a(n). Then set n' = floor(n/2^(a(n))), find a(n'), and so on.
Equivalently, the number of bits of n, starting from the least significant, in which the number of 0's first exceeds the number of 1's (including 0's above the most significant bit of n if necessary). - Kevin Ryde, Sep 30 2024

Examples

			a(37) = 1 + a(floor(37/2)) + a(floor(37/2^(a(floor(37/2)) + 1)))
  = 1 + a(18) + a(floor(37/2^(a(18) + 1)))
  = 1 + 1 + a(floor(37/2^(1 + 1)))
  = 2 + a(9)
  = 2 + 1 + a(floor(9/2)) + a(floor(9/2^(a(floor(9/2)) + 1)))
  = 3 + a(4) + a(floor(9/2^(a(4) + 1)))
  = 3 + 1 + a(floor(9/4))
  = 4 + a(2)
  = 5.
37 mod 2^5 = 5 = 00101, which is the postorder traversal of the binary tree with a root node and a single left child.
		

Crossrefs

Cf. A036991.

Programs

  • Maple
    a := proc(n) option remember; if 0 = n mod 2 then 1; else 1 + a(floor(n/2)) + a(floor(n/2^(a(floor(n/2)) + 1))); end if; end proc; # Petros Hadjicostas, Nov 20 2019
  • Mathematica
    a[n_] := a[n] = If[EvenQ[n], 1, 1 + a[Floor[n/2]] + a[ Floor[ n/2^( a[Floor[n/2]] + 1)]]]; a /@ Range[0, 100] (* Giovanni Resta, Nov 21 2019 *)
  • PARI
    A114567(n) = if(!(n%2),1,1+A114567(n\2) + A114567(n>>(1+A114567(n\2)))); \\ Antti Karttunen, Mar 30 2021, after the Maple-program
    
  • PARI
    a(n) = my(delta=1); for(i=0,oo, if(bittest(n,i), delta++, delta--||return(i+1))); \\ Kevin Ryde, Sep 30 2024

Formula

a(n) = 1, if n is even, and a(n) = 1 + a(floor(n/2)) + a(floor(n/2^{a(floor(n/2)) + 1})), if n is odd.
Previous Showing 11-14 of 14 results.