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

A031443 Digitally balanced numbers: positive numbers that in base 2 have the same number of 0's as 1's.

Original entry on oeis.org

2, 9, 10, 12, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 135, 139, 141, 142, 147, 149, 150, 153, 154, 156, 163, 165, 166, 169, 170, 172, 177, 178, 180, 184, 195, 197, 198, 201, 202, 204, 209, 210, 212, 216, 225, 226, 228, 232, 240, 527, 535, 539, 541, 542, 551
Offset: 1

Views

Author

Keywords

Comments

Also numbers k such that the binary digital mean dm(2, k) = (Sum_{i=1..d} 2*d_i - 1) / (2*d) = 0, where d is the number of digits in the binary representation of k and d_i the individual digits. - Reikku Kulon, Sep 21 2008
From Reikku Kulon, Sep 29 2008: (Start)
Each run of values begins with 2^(2k + 1) + 2^(k + 1) - 2^k - 1. The initial values increase according to the sequence {2^(k - 1), 2^(k - 2), 2^(k - 3), ..., 2^(k - k)}.
After this, the values follow a periodic sequence of increases by successive powers of two with single odd values interspersed.
Each run ends with an odd increase followed by increases of {2^(k - k), ..., 2^(k - 2), 2^(k - 1), 2^k}, finally reaching 2^(2k + 2) - 2^(k + 1).
Similar behavior occurs in other bases. (End)
Numbers k such that A000120(k)/A070939(k) = 1/2. - Ctibor O. Zizka, Oct 15 2008
Subsequence of A053754; A179888 is a subsequence. - Reinhard Zumkeller, Jul 31 2010
A000120(a(n)) = A023416(a(n)); A037861(a(n)) = 0.
A001700 gives number of terms having length 2*n in binary representation: A001700(n-1) = #{m: A070939(a(m))=2*n}. - Reinhard Zumkeller, Jun 08 2011
The number of terms below 2^k is A079309(floor(k/2)) for k > 1. - Amiram Eldar, Nov 21 2020

Examples

			9 is a term because '1001' contains 2 '0's and 2 '1's.
		

Crossrefs

Subsequence of A053754.
Row n = 2 of A378000.
Terms of binary width n are enumerated by A001700.

Programs

  • Haskell
    -- See link, showing that Ulrich Schimkes formula provides a very efficient algorithm. Reinhard Zumkeller, Jun 15 2011
    
  • Magma
    [ n: n in [2..250] | Multiplicity({* z: z in Intseq(n,2) *}, 0) eq &+Intseq(n,2) ];  // Bruno Berselli, Jun 07 2011
    
  • Maple
    a:=proc(n) local nn, n1, n0: nn:=convert(n,base,2): n1:=add(nn[i],i=1..nops(nn)): n0:=nops(nn)-n1: if n0=n1 then n else end if end proc: seq(a(n), n = 1..240); # Emeric Deutsch, Jul 31 2008
  • Mathematica
    Select[Range[250],DigitCount[#,2,1]==DigitCount[#,2,0]&] (* Harvey P. Dale, Jul 22 2013 *)
    FromDigits[#,2]&/@DeleteCases[Flatten[Permutations/@Table[PadRight[{},2n,{1,0}],{n,5}],1],?(#[[1]]==0&)]//Sort (* _Harvey P. Dale, May 30 2016 *)
  • PARI
    for(n=1,100,b=binary(n); l=length(b); if(sum(i=1,l, component(b,i))==l/2,print1(n,",")))
    
  • PARI
    is(n)=hammingweight(n)==hammingweight(bitneg(n,#binary(n))) \\ Charles R Greathouse IV, Mar 29 2013
    
  • PARI
    is(n)=2*hammingweight(n)==exponent(n)+1 \\ Charles R Greathouse IV, Apr 18 2020
    
  • Perl
    for my $half ( 1 .. 4 ) {
      my $N = 2 * $half;  # only even widths apply
      my $vector = (1 << ($N-1)) | ((1 << ($N/2-1)) - 1);  # first key
      my $n = 1; $n *= $_ for 2 .. $N;    # N!
      my $d = 1; $d *= $_ for 2 .. $N/2;  # (N/2)!
      for (1 .. $n/($d*$d*2)) {
        print "$vector, ";
        my ($v, $d) = ($vector, 0);
        until ($v & 1 or !$v) { $d = ($d << 1)|1; $v >>= 1 }
        $vector += $d + 1 + (($v ^ ($v + 1)) >> 2);  # next key
      }
    } # Ruud H.G. van Tol, Mar 30 2014
    
  • Python
    from sympy.utilities.iterables import multiset_permutations
    A031443_list = [int('1'+''.join(p),2) for n in range(1,10) for p in multiset_permutations('0'*n+'1'*(n-1))] # Chai Wah Wu, Nov 15 2019

Formula

a(n+1) = a(n) + 2^k + 2^(m-1) - 1 + floor((2^(k+m) - 2^k)/a(n))*(2^(2*m) + 2^(m-1)) where k is the largest integer such that 2^k divides a(n) and m is the largest integer such that 2^m divides a(n)/2^k+1. - Ulrich Schimke (UlrSchimke(AT)aol.com)
A145037(a(n)) = 0. - Reikku Kulon, Oct 02 2008

A053754 If k is in the sequence then 2*k and 2*k+1 are not (and 0 is in the sequence); when written in binary k has an even number of bits (0 has 0 digits).

Original entry on oeis.org

0, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148
Offset: 1

Views

Author

Henry Bottomley, Apr 06 2000

Keywords

Comments

Runs of successive terms with same number of bits have length twice powers of 4 (A081294). [Clarified by Michel Marcus, Oct 21 2020]
The sequence A081294 counts compositions of even numbers - Gus Wiseman, Aug 12 2021
A031443 is a subsequence; A179888 is the intersection of this sequence and A032925. - Reinhard Zumkeller, Jul 31 2010
The lower and upper asymptotic densities of this sequence are 1/3 and 2/3, respectively. - Amiram Eldar, Feb 01 2021
From Gus Wiseman, Aug 10 2021: (Start)
Also numbers k such that the k-th composition in standard order (row k of A066099) has even sum. The terms and corresponding compositions begin:
0: () 2: (2) 8: (4)
3: (1,1) 9: (3,1)
10: (2,2)
11: (2,1,1)
12: (1,3)
13: (1,2,1)
14: (1,1,2)
15: (1,1,1,1)
The following pertain to compositions in standard order: A000120, A029837, A070939, A066099, A124767.
(End)

Crossrefs

Positions of even terms in A029837 with offset 0.
The complement (the odd version) is A053738, counted by A000302.
The version for Heinz numbers of partitions is A300061, counted by A058696.

Programs

  • Haskell
    a053754 n = a053754_list !! (n-1)
    a053754_list = 0 : filter (even . a070939) [1..]
    -- Reinhard Zumkeller, Apr 18 2015
    
  • Mathematica
    Select[Range[0, 150], EvenQ @ IntegerLength[#, 2] &] (* Amiram Eldar, Feb 01 2021 *)
  • PARI
    lista(nn) = {my(va = vector(nn)); for (n=2, nn, my(k=va[n-1]+1); while (#select(x->(x==k\2), va), k++); va[n] = k;); va;} \\ Michel Marcus, Oct 20 2020
    
  • PARI
    a(n) = n-1 + (1<Kevin Ryde, Apr 30 2021

Extensions

Offset corrected by Reinhard Zumkeller, Jul 30 2010

A023717 Numbers with no 3's in base-4 expansion.

Original entry on oeis.org

0, 1, 2, 4, 5, 6, 8, 9, 10, 16, 17, 18, 20, 21, 22, 24, 25, 26, 32, 33, 34, 36, 37, 38, 40, 41, 42, 64, 65, 66, 68, 69, 70, 72, 73, 74, 80, 81, 82, 84, 85, 86, 88, 89, 90, 96, 97, 98, 100, 101, 102, 104, 105, 106, 128, 129, 130, 132, 133, 134, 136, 137, 138
Offset: 0

Views

Author

Keywords

Comments

A032925 is the intersection of this sequence and A023705; cf. A179888. - Reinhard Zumkeller, Jul 31 2010
Fixed point of the morphism: 0-> 0,1,2; 1-> 4,5,6; 2-> 8,9,10; ...; n-> 4n,4n+1,4n+2. - Philippe Deléham, Oct 22 2011

Crossrefs

Programs

  • C
    uint32_t a_next(uint32_t a_n) {
        uint32_t t = ((a_n ^ 0xaaaaaaaa) | 0x55555555) >> 1;
        return (a_n - t) & t;
    } // Falk Hüffner, Jan 22 2022
    
  • Haskell
    a023717 n = a023717_list !! (n-1)
    a023717_list = filter f [0..] where
       f x = x < 3 || (q < 3 && f x') where (x', q) = divMod x 4
    -- Reinhard Zumkeller, Apr 18 2015
    
  • Julia
    function a(n)
        m, r, b = n, 0, 1
        while m > 0
            m, q = divrem(m, 3)
            r += b * q
            b *= 4
        end
    r end; [a(n) for n in 0:58] |> println # Peter Luschny, Jan 03 2021
    
  • Mathematica
    Select[ Range[ 0, 140 ], (Count[ IntegerDigits[ #, 4 ], 3 ]==0)& ]
  • PARI
    a(n)=if(n<1,0,if(n%3,a(n-1)+1,4*a(n/3)))
    
  • PARI
    a(n)=if(n<1,0,4*a(floor(n/3))+n-3*floor(n/3))
    
  • Python
    from gmpy2 import digits
    def A023717(n): return int(digits(n,3),4) # Chai Wah Wu, May 06 2025

Formula

a(n) = Sum_{i=0..m} d(i)*4^i, where Sum_{i=0..m} d(i)*3^i is the base-3 representation of n. - Clark Kimberling
a(3n) = 4*a(n); a(3n+1) = 4*a(n)+1; a(3n+2) = 4*a(n)+2; a(n) = 4*a(floor(n/3)) + n - 3*floor(n/3). - Benoit Cloitre, Apr 27 2003
a(n) = Sum_{k>=0} A030341(n,k)*4^k. - Philippe Deléham, Oct 22 2011

A023705 Numbers with no 0's in base-4 expansion.

Original entry on oeis.org

1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15, 21, 22, 23, 25, 26, 27, 29, 30, 31, 37, 38, 39, 41, 42, 43, 45, 46, 47, 53, 54, 55, 57, 58, 59, 61, 62, 63, 85, 86, 87, 89, 90, 91, 93, 94, 95, 101, 102, 103, 105, 106, 107, 109, 110, 111, 117, 118, 119, 121, 122, 123
Offset: 1

Views

Author

Keywords

Comments

A032925 is the intersection of this sequence and A023717; cf. A179888. - Reinhard Zumkeller, Jul 31 2010

Crossrefs

Zeroless numbers in some other bases <= 10: A000042 (base 2), A032924 (base 3), A248910 (base 6), A255805 (base 8), A255808 (base 9), A052382 (base 10).
Cf. A100968 (subsequence).

Programs

  • C
    #include 
    uint32_t a_next(uint32_t a_n) { return (a_n + 1) | ((a_n & (a_n + 0xaaaaaaab)) >> 1); } /* Falk Hüffner, Jan 22 2022 */
    
  • Haskell
    a023705 n = a023705_list !! (n-1)
    a023705_list = iterate f 1 where
       f x = 1 + if r < 3 then x else 4 * f x'
             where (x', r) = divMod x 4
    -- Reinhard Zumkeller, Mar 06 2015, Oct 19 2011
    
  • Magma
    [n: n in [1..130] | not 0 in Intseq(n,4)]; // Vincenzo Librandi, Oct 04 2018
    
  • Maple
    R:= [1,2,3]: A:= 1,2,3:
    for i from 1 to 4 do
      R:= map(t -> (4*t+1,4*t+2,4*t+3), R);
      A:= A, op(R);
    od:
    A; # Robert Israel, Oct 04 2018
  • Mathematica
    Select[ Range[ 120 ], (Count[ IntegerDigits[ #, 4 ], 0 ]==0)& ]
    Select[Range[200],DigitCount[#,4,0]==0&] (* Harvey P. Dale, Dec 23 2015 *)
  • PARI
    isok(n) = vecmin(digits(n, 4)); \\ Michel Marcus, Jul 04 2015
    
  • Python
    from sympy import integer_log
    def A023705(n):
        m = integer_log(k:=(n<<1)+1,3)[0]
        return sum(1+(k-3**m)//(3**j<<1)%3<<(j<<1) for j in range(m)) # Chai Wah Wu, Jun 27 2025

Formula

G.f. g(x) satisfies g(x) = (x+2*x^2+3*x^3)/(1-x^3) + 4*(x+x^2+x^3)*g(x^3). - Robert Israel, Oct 04 2018

A032925 Numbers whose set of base-4 digits is a subset of {1,2}.

Original entry on oeis.org

1, 2, 5, 6, 9, 10, 21, 22, 25, 26, 37, 38, 41, 42, 85, 86, 89, 90, 101, 102, 105, 106, 149, 150, 153, 154, 165, 166, 169, 170, 341, 342, 345, 346, 357, 358, 361, 362, 405, 406, 409, 410, 421, 422, 425, 426, 597, 598, 601, 602, 613, 614, 617, 618, 661, 662, 665
Offset: 1

Views

Author

Keywords

Comments

Intersection of A023705 and A023717; A179888 is the intersection of this sequence and A053754. - Reinhard Zumkeller, Jul 31 2010

Crossrefs

Programs

  • C
    #include 
    uint32_t a_next(uint32_t a_n) {
        uint32_t t = (a_n + 0x55555556) ^ 0x55555555;
        return (a_n - t) & t;
    } /* Falk Hüffner, Jan 22 2022 */
  • Haskell
    import Data.List (transpose)
    a032925 n = a032925_list !! (n-1)
    a032925_list = 1 : 2 : (concat $ transpose [map (+ 1) fs, map (+ 2) fs])
                   where fs = map (* 4) a032925_list
    -- Reinhard Zumkeller, Apr 18 2015
    
  • Magma
    [n: n in [1..1000] | Set(IntegerToSequence(n, 4)) subset {1, 2}]; // Vincenzo Librandi, Jun 05 2012
    
  • Maple
    A032925 := proc(n)
        option remember;
        if n <= 2 then
            n;
        else
            if type(n,'even') then
                2+4*procname(n/2-1) ;
            else
                1+4*procname(floor(n/2)) ;
            end if;
        end if;
    end proc:
    seq(A032925(n),n=1..100) ;  # R. J. Mathar, Sep 07 2016
  • Mathematica
    Flatten[Table[FromDigits[#,4]&/@Tuples[{1,2},n],{n,5}]] (* Vincenzo Librandi, Jun 05 2012 *)

Formula

a(2n) = 4a(n-1) + 2, a(2n+1) = 4a(n) + 1. - Ralf Stephan, Oct 07 2003, corrected by R. J. Mathar, Sep 07 2016

A374625 In the binary expansion of n, expand bits 1 -> 01 and 0 -> 10.

Original entry on oeis.org

2, 1, 6, 5, 26, 25, 22, 21, 106, 105, 102, 101, 90, 89, 86, 85, 426, 425, 422, 421, 410, 409, 406, 405, 362, 361, 358, 357, 346, 345, 342, 341, 1706, 1705, 1702, 1701, 1690, 1689, 1686, 1685, 1642, 1641, 1638, 1637, 1626, 1625, 1622, 1621, 1450, 1449, 1446
Offset: 0

Views

Author

Darío Clavijo, Jul 14 2024

Keywords

Comments

This is essentialy the Manchester encoding (defined by convention in IEEE802.3 opposed to the original version where the mappings are inverted published by G. E. Thomas in 1949 see ref) which transforms each bit by representing 1 as 01 and 0 as 10, ensuring a transition occurs in the middle of each bit period for synchronization.

Examples

			a(5) = 25 because:
  5 is 101 and:
   1 |  0 |  1
  01 | 10 | 01
  And: 11001 is 25.
		

References

  • Andrew S. Tanenbaum, Computer Networks (4th ed.), Prentice Hall, 2002, Pages 274-275, ISBN 0-13-066102-3.

Crossrefs

Programs

  • Maple
    a:= n-> 2-(n mod 2)+`if`(n<2, 0, 4*a(iquo(n, 2))):
    seq(a(n), n=0..50);  # Alois P. Heinz, Jul 15 2024
  • Mathematica
    A374625[n_] := FromDigits[2 - IntegerDigits[n, 2], 4];
    Array[A374625, 100, 0] (* Paolo Xausa, Jul 16 2024 *)
  • Python
    def a(n):
      s=''
      for b in bin(n)[2:]:
        s += '01'*(b=='1') + '10'*(b=='0')
      return int(s,2)
    print([a(n) for n in range(0,51)])
    
  • Python
    def a(n):
      d = {'0': '10', '1': '01'}
      return int(''.join(map(d.get, bin(n)[2:])), 2)
    print([a(n) for n in range(0,51)]) # Jason Yuen, Jul 15 2024
    
  • Python
    a = lambda n: int(''.join("101"[b=='1':(b=='1')+2] for b in bin(n)[2:]), 2)
    # Peter Luschny, Jul 15 2024
    
  • Python
    def A374625(n): return ((1<<(n.bit_length()<<1)+1)-2)//3-int(bin(n)[2:],4) if n else 2 # Chai Wah Wu, Jul 16 2024

Formula

a(n) = a(n+1) + 1 for n even.
a(n) = A030101(A179888(A030101(n))) for n odd.
a(2*n) = 4*a(n) + 2 for n>=1.
a(2*n+1) = 4*a(n) + 1 for n>=1.

A132679 Starting with a(1)=1 and a(2)=2: if m is a term then also 4*m and 4*m+3.

Original entry on oeis.org

1, 2, 4, 7, 8, 11, 16, 19, 28, 31, 32, 35, 44, 47, 64, 67, 76, 79, 112, 115, 124, 127, 128, 131, 140, 143, 176, 179, 188, 191, 256, 259, 268, 271, 304, 307, 316, 319, 448, 451, 460, 463, 496, 499, 508, 511, 512, 515, 524, 527, 560, 563, 572, 575, 704, 707, 716
Offset: 1

Views

Author

Reinhard Zumkeller, Aug 26 2007

Keywords

Comments

Subsequence of A000069; A010060(a(n))=1; A000120(a(n)) mod 2 = 1;
A000079, A083420, A002042, A002089 are subsequences.

Crossrefs

Cf. A179888. [From Reinhard Zumkeller, Jul 31 2010]

Programs

  • Haskell
    import Data.Set (fromList, insert, deleteFindMin)
    a132679 n = a132679_list !! (n-1)
    a132679_list = f $ fromList [1,2] where
       f s = m : f (insert (4*m) $ insert (4*m+3) s') where
           (m,s') = deleteFindMin s
    -- Reinhard Zumkeller, Oct 29 2011
  • Mathematica
    Union[Nest[Flatten[{#,4#,4#+3}]&,{1,2},4]] (* Harvey P. Dale, Aug 02 2013 *)

A196168 In binary representation of n: replace each 0 with 1, and each 1 with 10.

Original entry on oeis.org

1, 2, 5, 10, 11, 22, 21, 42, 23, 46, 45, 90, 43, 86, 85, 170, 47, 94, 93, 186, 91, 182, 181, 362, 87, 174, 173, 346, 171, 342, 341, 682, 95, 190, 189, 378, 187, 374, 373, 746, 183, 366, 365, 730, 363, 726, 725, 1450, 175, 350, 349, 698, 347, 694, 693, 1386
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 28 2011

Keywords

Comments

All terms are numbers with no two adjacent zeros in binary representation, cf. A003754;
a(odd) = even and a(even) = odd;
A023416(a(n)) <= A000120(a(n)), equality iff n = 2^k - 1 for k > 0;
A055010(n+1) = A196168(A000079(n));
A000120(a(n)) = A070939(n);
A023416(a(n)) = A000120(n);
A070939(a(n)) = A070939(n) + A000120(n).

Examples

			n =  7 ->  111 ->  101010 ->  a(7) = 42;
n =  8 -> 1000 ->   10111 ->  a(8) = 23;
n =  9 -> 1001 ->  101110 ->  a(9) = 46;
n = 10 -> 1010 ->  101101 -> a(10) = 45;
n = 11 -> 1011 -> 1011010 -> a(11) = 90;
n = 12 -> 1100 ->  101011 -> a(12) = 43.
		

Crossrefs

Programs

  • Haskell
    import Data.List (unfoldr)
    a196168 0 = 1
    a196168 n = foldl (\v b -> (2 * v + 1)*(b + 1)) 0 $ reverse $ unfoldr
       (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2) n
       where r v b = (2 * v + 1)*(b+1)
    
  • Mathematica
    Table[FromDigits[Flatten[IntegerDigits[n,2]/.{{0->1,1->{1,0}}}],2],{n,0,120}] (* Harvey P. Dale, Dec 12 2017 *)
  • Python
    def a(n):
        b = bin(n)[2:]
        return int(b.replace('1', 't').replace('0', '1').replace('t', '10'), 2)
    print([a(n) for n in range(56)]) # Michael S. Branicky, Oct 28 2021

Formula

n = Sum_{i=0..1} b(i)*2^i with 0 <= b(i) <= 1, L >= 0, then a(n) = h(0,L) with h(v,i) = if i > L then v, otherwise h((2*v+1)*(b(i)+1),i-1).
From Jeffrey Shallit, Oct 28 2021: (Start)
a(n) satisfies the recurrences:
a(2n+1) = 2*a(2n)
a(4n) = -2*a(n) + 3*a(2n)
a(8n+2) = -8*a(n) + 8*a(2n) + a(4n+2)
a(8n+6) = -4*a(2n) + 5*a(4n+2)
which shows that a(n) is a 2-regular sequence. (End)
Showing 1-8 of 8 results.