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.

A386705 a(n) = sum of the 2^(n-1) even positive integers having bit length 2*n and in which, when written in binary, each run of 0's is of exactly the same length as the run of 1's immediately before it.

Original entry on oeis.org

2, 22, 192, 1576, 12704, 101856, 815360, 6524032, 52194816, 417564160, 3340525568, 26724231168, 213793906688, 1710351376384, 13682811273216, 109462490742784, 875699927121920, 7005599419465728, 56044795360968704, 448358362898759680, 3586866903213146112, 28694935225753403392
Offset: 1

Views

Author

Paolo Xausa, Aug 28 2025

Keywords

Comments

Row sums of A166751, when viewed as an irregular triangle whose row terms have the same number of bits (see the Example section there).

Examples

			For n = 3, the 2^(n-1) terms with bit length 2*n = 6 satisfying the criteria are (in binary): 101010, 101100, 110010 and 111000, corresponding (in decimal) to 42, 44, 50 and 56, giving a sum of 192.
		

Crossrefs

Cf. A166751.

Programs

  • Mathematica
    A386705[n_] := With[{b = Array[IntegerDigits[4^# - 2^#, 2] &, n]}, Total[Map[FromDigits[Flatten[#], 2] &, Map[b[[#]] &, Map[Permutations, IntegerPartitions[n]], {2}], {2}], 2]];
    Array[A386705, 20]

Formula

Empirical: a(n) = 12*a(n-1) - 36*a(n-2) + 32*a(n-3), with a(1) = 2, a(2) = 22, a(3) = 192.

A387269 Numbers whose binary expansion consists of alternating runs of 1's and 0's where each run of 0's is exactly one longer than the preceding run of 1's, and the expansion ends with a 0-run.

Original entry on oeis.org

4, 24, 36, 112, 152, 196, 292, 480, 624, 792, 900, 1176, 1220, 1572, 1984, 2340, 2528, 3184, 3608, 3844, 4720, 4888, 4996, 6296, 6340, 7204, 8064, 9368, 9412, 9764, 10176, 12580, 12768, 14448, 15384, 15876, 18724, 18912, 19568, 19992, 20228, 25200, 25368, 25476
Offset: 1

Views

Author

Ahmet Caglar Saygili, Aug 24 2025

Keywords

Comments

Every term is even (since the binary ends with a 0-run).
Writing the binary word as consecutive pairs 1^{a_1}0^{a_1+1}1^{a_2}0^{a_2+1} ..., the total number of 0's exceeds the total number of 1's by the number of pairs.
Single-pair subfamily 1^{k}0^{k+1}_2, with k >= 1, is A059153(k-1).
Let f(n) = n & (2n) (bitwise AND; A213370). If x has binary run pairs 1^{L_i+1}0^{L_i} (MSB->LSB) as in A387270, then f(x) has pairs 1^{L_i}0^{L_i+1}. Thus f maps A387270 bijectively onto this sequence. Reason: n & (2n) has 1-bits exactly where n has adjacent 1-bits, which shortens every 1-run by 1 and lengthens the following 0-run by 1. Conversely, g(n) = n | floor(n/2) increases each 1-run by 1 and shortens the following 0-run by 1, mapping this sequence back to A387270. Examples: f(6) = 4 (110_2 -> 100_2), f(28) = 24 (11100_2 -> 11000_2); g(24) = 28 (11000_2 -> 11100_2), g(36) = 54 (100100_2 -> 110110_2).

Examples

			36 = 100100_2 is a term since its pairs of (1 then 0) runs are (1,2), (1,2).
		

Crossrefs

Programs

  • Julia
    function ok(n::Integer)::Bool
        n > 0 && iseven(n) || return false
        x = unsigned(n)
        while x != 0
            z = trailing_zeros(x); x >>= z
            o = trailing_ones(x)
            z == o + 1 || return false
            x >>= o
        end
        true
    end
    [k for k in 0:10^5 if ok(k)]
    
  • PARI
    isok(k) = if (!(k%2), my(b=binary(k), pos=1, d, dd); for (i=1, #b-1, if (b[i] != b[i+1], if (b[i], d = i-pos+1; pos = i+1, dd = i-pos+1; pos = i+1; if (dd != d+1, return(0))))); dd = #b - pos+1; if (dd != d+1, return(0)); return(1);); \\ Michel Marcus, Aug 26 2025
  • Python
    from itertools import groupby
    def ok(n):
        L = [len(list(g)) for k, g in groupby(bin(n)[2:])]
        return (m:=len(L))&1 == 0 and all(L[2*j]+1 == L[2*j+1] for j in range(m>>1))
    print([k for k in range(10**5) if ok(k)]) # Michael S. Branicky, Aug 25 2025
    
Showing 1-2 of 2 results.