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-10 of 28 results. Next

A211676 Number of n-bit numbers in A077436.

Original entry on oeis.org

1, 1, 2, 3, 4, 5, 6, 9, 14, 24, 37, 63, 93, 162, 233, 376, 582, 921, 1497, 2435, 4007, 6696, 10998, 18310, 30340, 50792, 84897, 143079, 239266, 401652, 673887, 1131226, 1900203, 3197114, 5373366, 9039360, 15208992, 25592325, 43064747, 72494816, 122025100
Offset: 0

Views

Author

T. D. Noe, Apr 27 2012

Keywords

Comments

That is, the number of binary numbers b having n bits and B(b) = B(b^2), where the function B gives the number of ones in a binary number. For numbers written in base 10, the corresponding sequence is A147523.

Crossrefs

Programs

  • Mathematica
    Join[{1}, Table[cnt = 0; Do[If[Total[IntegerDigits[i, 2]] == Total[IntegerDigits[i^2, 2]], cnt++], {i, 2^(n-1), 2^n-1}]; cnt, {n, 15}]]

Extensions

a(28)-a(38) from Donovan Johnson, Apr 29 2012
a(39)-a(40) from Donovan Johnson, Aug 25 2012

A000120 1's-counting sequence: number of 1's in binary expansion of n (or the binary weight of n).

Original entry on oeis.org

0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3
Offset: 0

Views

Author

Keywords

Comments

The binary weight of n is also called Hamming weight of n. [The term "Hamming weight" was named after the American mathematician Richard Wesley Hamming (1915-1998). - Amiram Eldar, Jun 16 2021]
a(n) is also the largest integer such that 2^a(n) divides binomial(2n, n) = A000984(n). - Benoit Cloitre, Mar 27 2002
To construct the sequence, start with 0 and use the rule: If k >= 0 and a(0), a(1), ..., a(2^k-1) are the first 2^k terms, then the next 2^k terms are a(0) + 1, a(1) + 1, ..., a(2^k-1) + 1. - Benoit Cloitre, Jan 30 2003
An example of a fractal sequence. That is, if you omit every other number in the sequence, you get the original sequence. And of course this can be repeated. So if you form the sequence a(0 * 2^n), a(1 * 2^n), a(2 * 2^n), a(3 * 2^n), ... (for any integer n > 0), you get the original sequence. - Christopher.Hills(AT)sepura.co.uk, May 14 2003
The n-th row of Pascal's triangle has 2^k distinct odd binomial coefficients where k = a(n) - 1. - Lekraj Beedassy, May 15 2003
Fixed point of the morphism 0 -> 01, 1 -> 12, 2 -> 23, 3 -> 34, 4 -> 45, etc., starting from a(0) = 0. - Robert G. Wilson v, Jan 24 2006
a(n) is the number of times n appears among the mystery calculator sequences: A005408, A042964, A047566, A115419, A115420, A115421. - Jeremy Gardiner, Jan 25 2006
a(n) is the number of solutions of the Diophantine equation 2^m*k + 2^(m-1) + i = n, where m >= 1, k >= 0, 0 <= i < 2^(m-1); a(5) = 2 because only (m, k, i) = (1, 2, 0) [2^1*2 + 2^0 + 0 = 5] and (m, k, i) = (3, 0, 1) [2^3*0 + 2^2 + 1 = 5] are solutions. - Hieronymus Fischer, Jan 31 2006
The first appearance of k, k >= 0, is at a(2^k-1). - Robert G. Wilson v, Jul 27 2006
Sequence is given by T^(infinity)(0) where T is the operator transforming any word w = w(1)w(2)...w(m) into T(w) = w(1)(w(1)+1)w(2)(w(2)+1)...w(m)(w(m)+1). I.e., T(0) = 01, T(01) = 0112, T(0112) = 01121223. - Benoit Cloitre, Mar 04 2009
For n >= 2, the minimal k for which a(k(2^n-1)) is not multiple of n is 2^n + 3. - Vladimir Shevelev, Jun 05 2009
Triangle inequality: a(k+m) <= a(k) + a(m). Equality holds if and only if C(k+m, m) is odd. - Vladimir Shevelev, Jul 19 2009
a(k*m) <= a(k) * a(m). - Robert Israel, Sep 03 2023
The number of occurrences of value k in the first 2^n terms of the sequence is equal to binomial(n, k), and also equal to the sum of the first n - k + 1 terms of column k in the array A071919. Example with k = 2, n = 7: there are 21 = binomial(7,2) = 1 + 2 + 3 + 4 + 5 + 6 2's in a(0) to a(2^7-1). - Brent Spillner (spillner(AT)acm.org), Sep 01 2010, simplified by R. J. Mathar, Jan 13 2017
Let m be the number of parts in the listing of the compositions of n as lists of parts in lexicographic order, a(k) = n - length(composition(k)) for all k < 2^n and all n (see example); A007895 gives the equivalent for compositions into odd parts. - Joerg Arndt, Nov 09 2012
From Daniel Forgues, Mar 13 2015: (Start)
Just tally up row k (binary weight equal k) from 0 to 2^n - 1 to get the binomial coefficient C(n,k). (See A007318.)
0 1 3 7 15
0: O | . | . . | . . . . | . . . . . . . . |
1: | O | O . | O . . . | O . . . . . . . |
2: | | O | O O . | O O . O . . . |
3: | | | O | O O O . |
4: | | | | O |
Due to its fractal nature, the sequence is quite interesting to listen to.
(End)
The binary weight of n is a particular case of the digit sum (base b) of n. - Daniel Forgues, Mar 13 2015
The mean of the first n terms is 1 less than the mean of [a(n+1),...,a(2n)], which is also the mean of [a(n+2),...,a(2n+1)]. - Christian Perfect, Apr 02 2015
a(n) is also the largest part of the integer partition having viabin number n. The viabin number of an integer partition is defined in the following way. Consider the southeast border of the Ferrers board of the integer partition and consider the binary number obtained by replacing each east step with 1 and each north step, except the last one, with 0. The corresponding decimal form is, by definition, the viabin number of the given integer partition. "Viabin" is coined from "via binary". For example, consider the integer partition [2, 2, 2, 1]. The southeast border of its Ferrers board yields 10100, leading to the viabin number 20. - Emeric Deutsch, Jul 20 2017
a(n) is also known as the population count of the binary representation of n. - Chai Wah Wu, May 19 2020

Examples

			Using the formula a(n) = a(floor(n / floor_pow4(n))) + a(n mod floor_pow4(n)):
  a(4) = a(1) + a(0) = 1,
  a(8) = a(2) + a(0) = 1,
  a(13) = a(3) + a(1) = 2 + 1 = 3,
  a(23) = a(1) + a(7) = 1 + a(1) + a(3) = 1 + 1 + 2 = 4.
_Gary W. Adamson_ points out (Jun 03 2009) that this can be written as a triangle:
  0,
  1,
  1,2,
  1,2,2,3,
  1,2,2,3,2,3,3,4,
  1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
  1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
  1,2,2,3,2,3,...
where the rows converge to A063787.
From _Joerg Arndt_, Nov 09 2012: (Start)
Connection to the compositions of n as lists of parts (see comment):
[ #]:   a(n)  composition
[ 0]:   [0]   1 1 1 1 1
[ 1]:   [1]   1 1 1 2
[ 2]:   [1]   1 1 2 1
[ 3]:   [2]   1 1 3
[ 4]:   [1]   1 2 1 1
[ 5]:   [2]   1 2 2
[ 6]:   [2]   1 3 1
[ 7]:   [3]   1 4
[ 8]:   [1]   2 1 1 1
[ 9]:   [2]   2 1 2
[10]:   [2]   2 2 1
[11]:   [3]   2 3
[12]:   [2]   3 1 1
[13]:   [3]   3 2
[14]:   [3]   4 1
[15]:   [4]   5
(End)
		

References

  • Jean-Paul Allouche and Jeffrey Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 119.
  • Donald E. Knuth, The Art of Computer Programming, vol. 4A, Combinatorial Algorithms, Section 7.1.3, Problem 41, p. 589. - N. J. A. Sloane, Aug 03 2012
  • Manfred R. Schroeder, Fractals, Chaos, Power Laws. W.H. Freeman, 1991, p. 383.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

The basic sequences concerning the binary expansion of n are this one, A000788, A000069, A001969, A023416, A059015, A007088.
Partial sums see A000788. For run lengths see A131534. See also A001792, A010062.
Number of 0's in n: A023416 and A080791.
a(n) = n - A011371(n).
Sum of digits of n written in bases 2-16: this sequence, A053735, A053737, A053824, A053827, A053828, A053829, A053830, A007953, A053831, A053832, A053833, A053834, A053835, A053836.
This is Guy Steele's sequence GS(3, 4) (see A135416).
Cf. A230952 (boustrophedon transform).
Cf. A070939 (length of binary representation of n).

Programs

  • Fortran
    c See link in A139351
    
  • Haskell
    import Data.Bits (Bits, popCount)
    a000120 :: (Integral t, Bits t) => t -> Int
    a000120 = popCount
    a000120_list = 0 : c [1] where c (x:xs) = x : c (xs ++ [x,x+1])
    -- Reinhard Zumkeller, Aug 26 2013, Feb 19 2012, Jun 16 2011, Mar 07 2011
    
  • Haskell
    a000120 = concat r
        where r = [0] : (map.map) (+1) (scanl1 (++) r)
    -- Luke Palmer, Feb 16 2014
    
  • Magma
    [Multiplicity(Intseq(n, 2), 1): n in [0..104]]; // Marius A. Burtea, Jan 22 2020
    
  • Magma
    [&+Intseq(n, 2):n in [0..104]]; // Marius A. Burtea, Jan 22 2020
  • Maple
    A000120 := proc(n) local w,m,i; w := 0; m := n; while m > 0 do i := m mod 2; w := w+i; m := (m-i)/2; od; w; end: wt := A000120;
    A000120 := n -> add(i, i=convert(n,base,2)): # Peter Luschny, Feb 03 2011
    with(Bits): p:=n->ilog2(n-And(n,n-1)): seq(p(binomial(2*n,n)),n=0..200) # Gary Detlefs, Jan 27 2019
  • Mathematica
    Table[DigitCount[n, 2, 1], {n, 0, 105}]
    Nest[Flatten[# /. # -> {#, # + 1}] &, {0}, 7] (* Robert G. Wilson v, Sep 27 2011 *)
    Table[Plus @@ IntegerDigits[n, 2], {n, 0, 104}]
    Nest[Join[#, # + 1] &, {0}, 7] (* IWABUCHI Yu(u)ki, Jul 19 2012 *)
    Log[2, Nest[Join[#, 2#] &, {1}, 14]] (* gives 2^14 term, Carlos Alves, Mar 30 2014 *)
  • PARI
    {a(n) = if( n<0, 0, 2*n - valuation((2*n)!, 2))};
    
  • PARI
    {a(n) = if( n<0, 0, subst(Pol(binary(n)), x ,1))};
    
  • PARI
    {a(n) = if( n<1, 0, a(n\2) + n%2)}; /* Michael Somos, Mar 06 2004 */
    
  • PARI
    a(n)=my(v=binary(n));sum(i=1,#v,v[i]) \\ Charles R Greathouse IV, Jun 24 2011
    
  • PARI
    a(n)=norml2(binary(n)) \\ better use {A000120=hammingweight}. - M. F. Hasler, Oct 09 2012, edited Feb 27 2020
    
  • PARI
    a(n)=hammingweight(n) \\ Michel Marcus, Oct 19 2013
    (Common Lisp) (defun floor-to-power (n pow) (declare (fixnum pow)) (expt pow (floor (log n pow)))) (defun enabled-bits (n) (if (< n 4) (n-th n (list 0 1 1 2)) (+ (enabled-bits (floor (/ n (floor-to-power n 4)))) (enabled-bits (mod n (floor-to-power n 4)))))) ; Stephen K. Touset (stephen(AT)touset.org), Apr 04 2007
    
  • Python
    def A000120(n): return bin(n).count('1') # Chai Wah Wu, Sep 03 2014
    
  • Python
    import numpy as np
    A000120 = np.array([0], dtype="uint8")
    for bitrange in range(25): A000120 = np.append(A000120, np.add(A000120, 1))
    print([A000120[n] for n in range(0, 105)]) # Karl-Heinz Hofmann, Nov 07 2022
    
  • Python
    def A000120(n): return n.bit_count() # Requires Python 3.10 or higher. - Pontus von Brömssen, Nov 08 2022
    
  • Python
    # Also see links.
    
  • SageMath
    def A000120(n):
        if n <= 1: return Integer(n)
        return A000120(n//2) + n%2
    [A000120(n) for n in range(105)]  # Peter Luschny, Nov 19 2012
    
  • SageMath
    def A000120(n) : return sum(n.digits(2)) # Eric M. Schmidt, Apr 26 2013
    
  • Scala
    (0 to 127).map(Integer.bitCount()) // _Alonso del Arte, Mar 05 2019
    

Formula

a(0) = 0, a(2*n) = a(n), a(2*n+1) = a(n) + 1.
a(0) = 0, a(2^i) = 1; otherwise if n = 2^i + j with 0 < j < 2^i, a(n) = a(j) + 1.
G.f.: Product_{k >= 0} (1 + y*x^(2^k)) = Sum_{n >= 0} y^a(n)*x^n. - N. J. A. Sloane, Jun 04 2009
a(n) = a(n-1) + 1 - A007814(n) = log_2(A001316(n)) = 2n - A005187(n) = A070939(n) - A023416(n). - Henry Bottomley, Apr 04 2001; corrected by Ralf Stephan, Apr 15 2002
a(n) = log_2(A000984(n)/A001790(n)). - Benoit Cloitre, Oct 02 2002
For n > 0, a(n) = n - Sum_{k=1..n} A007814(k). - Benoit Cloitre, Oct 19 2002
a(n) = n - Sum_{k>=1} floor(n/2^k) = n - A011371(n). - Benoit Cloitre, Dec 19 2002
G.f.: (1/(1-x)) * Sum_{k>=0} x^(2^k)/(1+x^(2^k)). - Ralf Stephan, Apr 19 2003
a(0) = 0, a(n) = a(n - 2^floor(log_2(n))) + 1. Examples: a(6) = a(6 - 2^2) + 1 = a(2) + 1 = a(2 - 2^1) + 1 + 1 = a(0) + 2 = 2; a(101) = a(101 - 2^6) + 1 = a(37) + 1 = a(37 - 2^5) + 2 = a(5 - 2^2) + 3 = a(1 - 2^0) + 4 = a(0) + 4 = 4; a(6275) = a(6275 - 2^12) + 1 = a(2179 - 2^11) + 2 = a(131 - 2^7) + 3 = a(3 - 2^1) + 4 = a(1 - 2^0) + 5 = 5; a(4129) = a(4129 - 2^12) + 1 = a(33 - 2^5) + 2 = a(1 - 2^0) + 3 = 3. - Hieronymus Fischer, Jan 22 2006
A fixed point of the mapping 0 -> 01, 1 -> 12, 2 -> 23, 3 -> 34, 4 -> 45, ... With f(i) = floor(n/2^i), a(n) is the number of odd numbers in the sequence f(0), f(1), f(2), f(3), f(4), f(5), ... - Philippe Deléham, Jan 04 2004
When read mod 2 gives the Morse-Thue sequence A010060.
Let floor_pow4(n) denote n rounded down to the next power of four, floor_pow4(n) = 4 ^ floor(log4 n). Then a(0) = 0, a(1) = 1, a(2) = 1, a(3) = 2, a(n) = a(floor(n / floor_pow4(n))) + a(n % floor_pow4(n)). - Stephen K. Touset (stephen(AT)touset.org), Apr 04 2007
a(n) = n - Sum_{k=2..n} Sum_{j|n, j >= 2} (floor(log_2(j)) - floor(log_2(j-1))). - Hieronymus Fischer, Jun 18 2007
a(n) = A138530(n, 2) for n > 1. - Reinhard Zumkeller, Mar 26 2008
a(A077436(n)) = A159918(A077436(n)); a(A000290(n)) = A159918(n). - Reinhard Zumkeller, Apr 25 2009
a(n) = A063787(n) - A007814(n). - Gary W. Adamson, Jun 04 2009
a(n) = A007814(C(2n, n)) = 1 + A007814(C(2n-1, n)). - Vladimir Shevelev, Jul 20 2009
For odd m >= 1, a((4^m-1)/3) = a((2^m+1)/3) + (m-1)/2 (mod 2). - Vladimir Shevelev, Sep 03 2010
a(n) - a(n-1) = { 1 - a(n-1) if and only if A007814(n) = a(n-1), 1 if and only if A007814(n) = 0, -1 for all other A007814(n) }. - Brent Spillner (spillner(AT)acm.org), Sep 01 2010
a(A001317(n)) = 2^a(n). - Vladimir Shevelev, Oct 25 2010
a(n) = A139351(n) + A139352(n) = Sum_k {A030308(n, k)}. - Philippe Deléham, Oct 14 2011
From Hieronymus Fischer, Jun 10 2012: (Start)
a(n) = Sum_{j = 1..m+1} (floor(n/2^j + 1/2) - floor(n/2^j)), where m = floor(log_2(n)).
General formulas for the number of digits >= d in the base p representation of n, where 1 <= d < p: a(n) = Sum_{j = 1..m+1} (floor(n/p^j + (p-d)/p) - floor(n/p^j)), where m=floor(log_p(n)); g.f.: g(x) = (1/(1-x))*Sum_{j>=0} (x^(d*p^j) - x^(p*p^j))/(1-x^(p*p^j)). (End)
a(n) = A213629(n, 1) for n > 0. - Reinhard Zumkeller, Jul 04 2012
a(n) = A240857(n,n). - Reinhard Zumkeller, Apr 14 2014
a(n) = log_2(C(2*n,n) - (C(2*n,n) AND C(2*n,n)-1)). - Gary Detlefs, Jul 10 2014
Sum_{n >= 1} a(n)/2n(2n+1) = (gamma + log(4/Pi))/2 = A344716, where gamma is Euler's constant A001620; see Sondow 2005, 2010 and Allouche, Shallit, Sondow 2007. - Jonathan Sondow, Mar 21 2015
For any integer base b >= 2, the sum of digits s_b(n) of expansion base b of n is the solution of this recurrence relation: s_b(n) = 0 if n = 0 and s_b(n) = s_b(floor(n/b)) + (n mod b). Thus, a(n) satisfies: a(n) = 0 if n = 0 and a(n) = a(floor(n/2)) + (n mod 2). This easily yields a(n) = Sum_{i = 0..floor(log_2(n))} (floor(n/2^i) mod 2). From that one can compute a(n) = n - Sum_{i = 1..floor(log_2(n))} floor(n/2^i). - Marek A. Suchenek, Mar 31 2016
Sum_{k>=1} a(k)/2^k = 2 * Sum_{k >= 0} 1/(2^(2^k)+1) = 2 * A051158. - Amiram Eldar, May 15 2020
Sum_{k>=1} a(k)/(k*(k+1)) = A016627 = log(4). - Bernard Schott, Sep 16 2020
a(m*(2^n-1)) >= n. Equality holds when 2^n-1 >= A000265(m), but also in some other cases, e.g., a(11*(2^2-1)) = 2 and a(19*(2^3-1)) = 3. - Pontus von Brömssen, Dec 13 2020
G.f.: A(x) satisfies A(x) = (1+x)*A(x^2) + x/(1-x^2). - Akshat Kumar, Nov 04 2023

A023758 Numbers of the form 2^i - 2^j with i >= j.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 7, 8, 12, 14, 15, 16, 24, 28, 30, 31, 32, 48, 56, 60, 62, 63, 64, 96, 112, 120, 124, 126, 127, 128, 192, 224, 240, 248, 252, 254, 255, 256, 384, 448, 480, 496, 504, 508, 510, 511, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022, 1023
Offset: 1

Views

Author

Keywords

Comments

Numbers whose digits in base 2 are in nonincreasing order.
Might be called "nialpdromes".
Subset of A077436. Proof: Since a(n) is of the form (2^i-1)*2^j, i,j >= 0, a(n)^2 = (2^(2i) - 2^(i+1))*2^(2j) + 2^(2j) where the first sum term has i-1 one bits and its 2j-th bit is zero, while the second sum term switches the 2j-th bit to one, giving i one bits, as in a(n). - Ralf Stephan, Mar 08 2004
Numbers whose binary representation contains no "01". - Benoit Cloitre, May 23 2004
Every polynomial with coefficients equal to 1 for the leading terms and 0 after that, evaluated at 2. For instance a(13) = x^4 + x^3 + x^2 at 2, a(14) = x^4 + x^3 + x^2 + x at 2. - Ben Paul Thurston, Jan 11 2008
From Gary W. Adamson, Jul 18 2008: (Start)
As a triangle by rows starting:
1;
2, 3;
4, 6, 7;
8, 12, 14, 15;
16, 24, 28, 30, 31;
...,
equals A000012 * A130123 * A000012, where A130123 = (1, 0,2; 0,0,4; 0,0,0,8; ...). Row sums of this triangle = A000337 starting (1, 5, 17, 49, 129, ...). (End)
First differences are A057728 = 1; 1; 1; 1; 2,1; 1; 4,2,1; 1; 8,4,2,1; 1; ... i.e., decreasing powers of 2, separated by another "1". - M. F. Hasler, May 06 2009
Apart from first term, numbers that are powers of 2 or the sum of some consecutive powers of 2. - Omar E. Pol, Feb 14 2013
From Andres Cicuttin, Apr 29 2016: (Start)
Numbers that can be digitally generated with twisted ring (Johnson) counters. This is, the binary digits of a(n) correspond to those stored in a shift register where the input bit of the first bit storage element is the inverted output of the last storage element. After starting with all 0’s, each new state is obtained by rotating the stored bits but inverting at each state transition the last bit that goes to the first position (see link).
Examples: for a(n) represented by three bits
Binary
a(5)= 4 -> 100 last bit = 0
a(6)= 6 -> 110 first bit = 1 (inverted last bit of previous number)
a(7)= 7 -> 111
and for a(n) represented by four bits
Binary
a(8) = 8 -> 1000
a(9) = 12 -> 1100 last bit = 0
a(10)= 14 -> 1110 first bit = 1 (inverted last bit of previous number)
a(11)= 15 -> 1111
(End)
Powers of 2 represented in bases which are terms of this sequence must always contain at least one digit which is also a power of 2. This is because 2^i mod (2^i - 2^j) = 2^j, which means the last digit always cycles through powers of 2 (or if i=j+1 then the first digit is a power of 2 and the rest are trailing zeros). The only known non-member of this sequence with this property is 5. - Ely Golden, Sep 05 2017
Numbers k such that k = 2^(1 + A000523(k)) - 2^A007814(k). - Daniel Starodubtsev, Aug 05 2021
A002260(n) = v(a(n)/2^v(a(n))+1) and A002024(n) = A002260(n) + v(a(n)) where v is the dyadic valuation (i.e., A007814). - Lorenzo Sauras Altuzarra, Feb 01 2023

Examples

			a(22) = 64 = 32 + 32 = 2^5 + a(16) = 2^A003056(20) + a(22-5-1).
a(23) = 96 = 64 + 32 = 2^6 + a(16) = 2^A003056(21) + a(23-6-1).
a(24) = 112 = 64 + 48 = 2^6 + a(17) = 2^A003056(22) + a(24-6-1).
		

Crossrefs

A000337(r) = sum of row T(r, c) with 0 <= c < r. See also A002024, A003056, A140129, A140130, A221975.
Cf. A007088, A130123, A101082 (complement), A340375 (characteristic function).
This is the base-2 version of A064222. First differences are A057728.
Subsequence of A077436, of A129523, of A277704, and of A333762.
Subsequences: A043569 (nonzero even terms, or equally, nonzero terms doubled), A175332, A272615, A335431, A000396 (its even terms only), A324200.
Positions of zeros in A049502, A265397, A277899, A284264.
Positions of ones in A283983, A283989.
Positions of nonzero terms in A341509 (apart from the initial zero).
Positions of squarefree terms in A260443.
Fixed points of A264977, A277711, A283165, A334666.
Distinct terms in A340632.
Cf. also A309758, A309759, A309761 (for analogous sequences).

Programs

  • Haskell
    import Data.Set (singleton, deleteFindMin, insert)
    a023758 n = a023758_list !! (n-1)
    a023758_list = 0 : f (singleton 1) where
    f s = x : f (if even x then insert z s' else insert z $ insert (z+1) s')
    where z = 2*x; (x, s') = deleteFindMin s
    -- Reinhard Zumkeller, Sep 24 2014, Dec 19 2012
    
  • Maple
    a:=proc(n) local n2,d: n2:=convert(n,base,2): d:={seq(n2[j]-n2[j-1],j=2..nops(n2))}: if n=0 then 0 elif n=1 then 1 elif d={0,1} or d={0} or d={1} then n else fi end: seq(a(n),n=0..2100); # Emeric Deutsch, Apr 22 2006
  • Mathematica
    Union[Flatten[Table[2^i - 2^j, {i, 0, 100}, {j, 0, i}]]] (* T. D. Noe, Mar 15 2011 *)
    Select[Range[0, 2^10], NoneTrue[Differences@ IntegerDigits[#, 2], # > 0 &] &] (* Michael De Vlieger, Sep 05 2017 *)
  • PARI
    for(n=0,2500,if(prod(k=1,length(binary(n))-1,component(binary(n),k)+1-component(binary(n),k+1))>0,print1(n,",")))
    
  • PARI
    A023758(n)= my(r=round(sqrt(2*n--))); (1<<(n-r*(r-1)/2)-1)<<(r*(r+1)/2-n)
    /* or, to illustrate the "decreasing digit" property and analogy to A064222: */
    A023758(n,show=0)={ my(a=0); while(n--, show & print1(a","); a=vecsort(binary(a+1)); a*=vector(#a,j,2^(j-1))~); a} \\ M. F. Hasler, May 06 2009
    
  • PARI
    is(n)=if(n<5,1,n>>=valuation(n,2);n++;n>>valuation(n,2)==1) \\ Charles R Greathouse IV, Jan 04 2016
    
  • PARI
    list(lim)=my(v=List([0]),t); for(i=1,logint(lim\1+1,2), t=2^i-1; while(t<=lim, listput(v,t); t*=2)); Set(v) \\ Charles R Greathouse IV, May 03 2016
    
  • Python
    def a_next(a_n): return (a_n | (a_n >> 1)) + (a_n & 1)
    a_n = 1; a = [0]
    for i in range(55): a.append(a_n); a_n = a_next(a_n) # Falk Hüffner, Feb 19 2022
    
  • Python
    from math import isqrt
    def A023758(n): return (1<<(m:=isqrt(n-1<<3)+1>>1))-(1<<(m*(m+1)-(n-1<<1)>>1)) # Chai Wah Wu, Feb 23 2025

Formula

a(n) = 2^s(n) - 2^((s(n)^2 + s(n) - 2n)/2) where s(n) = ceiling((-1 + sqrt(1+8n))/2). - Sam Alexander, Jan 08 2005
a(n) = 2^k + a(n-k-1) for 1 < n and k = A003056(n-2). The rows of T(r, c) = 2^r-2^c for 0 <= c < r read from right to left produce this sequence: 1; 2, 3; 4, 6, 7; 8, 12, 14, 15; ... - Frank Ellermann, Dec 06 2001
For n > 0, a(n) mod 2 = A010054(n). - Benoit Cloitre, May 23 2004
A140130(a(n)) = 1 and for n > 1: A140129(a(n)) = A002262(n-2). - Reinhard Zumkeller, May 14 2008
a(n+1) = (2^(n - r(r-1)/2) - 1) 2^(r(r+1)/2 - n), where r=round(sqrt(2n)). - M. F. Hasler, May 06 2009
Start with A000225. If k is in the sequence, then so is 2k. - Ralf Stephan, Aug 16 2013
G.f.: (x^2/((2-x)*(1-x)))*(1 + Sum_{k>=0} x^((k^2+k)/2)*(1 + x*(2^k-1))). The sum is related to Jacobi theta functions. - Robert Israel, Feb 24 2015
A049502(a(n)) = 0. - Reinhard Zumkeller, Jun 17 2015
a(n) = a(n-1) + a(n-d)/a(d*(d+1)/2 + 2) if n > 1, d > 0, where d = A002262(n-2). - Yuchun Ji, May 11 2020
A277699(a(n)) = a(n)^2, A306441(a(n)) = a(n+1). - Antti Karttunen, Feb 15 2021 (the latter identity from A306441)
Sum_{n>=2} 1/a(n) = A211705. - Amiram Eldar, Feb 20 2022

Extensions

Definition changed by N. J. A. Sloane, Jan 05 2008

A000337 a(n) = (n-1)*2^n + 1.

Original entry on oeis.org

0, 1, 5, 17, 49, 129, 321, 769, 1793, 4097, 9217, 20481, 45057, 98305, 212993, 458753, 983041, 2097153, 4456449, 9437185, 19922945, 41943041, 88080385, 184549377, 385875969, 805306369, 1677721601, 3489660929, 7247757313, 15032385537, 31138512897, 64424509441
Offset: 0

Views

Author

Keywords

Comments

a(n) also gives number of 0's in binary numbers 1 to 111..1 (n+1 bits). - Stephen G Penrice, Oct 01 2000
Numerator of m(n) = (m(n-1)+n)/2, m(0)=0. Denominator is A000079. - Reinhard Zumkeller, Feb 23 2002
a(n) is the number of directed column-convex polyominoes of area n+2 having along the lower contour exactly one vertical step that is followed by a horizontal step (a reentrant corner). - Emeric Deutsch, May 21 2003
a(n) is the number of bits in binary numbers from 1 to 111...1 (n bits). Partial sums of A001787. - Emeric Deutsch, May 24 2003
Genus of graph of n-cube = a(n-3) = 1+(n-4)*2^(n-3), n>1.
Sum of ordered partitions of n where each element is summed via T(e-1). See A066185 for more information. - Jon Perry, Dec 12 2003
a(n-2) is the number of Dyck n-paths with exactly one peak at height >= 3. For example, there are 5 such paths with n=4: UUUUDDDD, UUDUUDDD, UUUDDUDD, UDUUUDDD, UUUDDDUD. - David Callan, Mar 23 2004
Permutations in S_{n+2} avoiding 12-3 that contain the pattern 13-2 exactly once.
a(n) is prime for n = 2, 3, 7, 27, 51, 55, 81. a(n) is semiprime for n = 4, 5, 6, 8, 9, 10, 11, 13, 15, 19, 28, 32, 39, 57, 63, 66, 75, 97. - Jonathan Vos Post, Jul 18 2005
A member of the family of sequences defined by a(n) = Sum_{i=1..n} i*[c(1)*...*c(r)]^(i-1). This sequence has c(1)=2, A014915 has c(1)=3. - Ctibor O. Zizka, Feb 23 2008
Starting with 1 = row sums of A023758 as a triangle by rows: [1; 2,3; 4,6,7; 8,12,14,15; ...]. - Gary W. Adamson, Jul 18 2008
Equivalent formula given in Brehm: for each q >= 3 there exists a polyhedral map M_q of type {4, q} with [number of vertices] f_0 = 2^q and [genus] g = (2^(q-3))*(q-4) + 1 such that M_q and its dual have polyhedral embeddings in R^3 [McMullen et al.]. - Jonathan Vos Post, Jul 25 2009
Sums of rows of the triangle in A173787. - Reinhard Zumkeller, Feb 28 2010
This sequence is related to A000079 by a(n) = n*A000079(n)-Sum_{i=0..n-1} A000079(i). - Bruno Berselli, Mar 06 2012
(1 + 5*x + 17*x^2 + 49*x^3 + ...) = (1 + 2*x + 4*x^2 + 8*x^3 + ...) * (1 + 3*x + 7*x^2 + 15*x^3 + ...). - Gary W. Adamson, Mar 14 2012
The first barycentric coordinate of the centroid of Pascal triangles, assuming that numbers are weights, is A000295(n+1)/A000337(n), no matter what the triangle sides are. See attached figure. - César Eliud Lozada, Nov 14 2014
a(n) is the n-th number that is a sum of n positive n-th powers for n >= 1. a(4) = 49 = A003338(4). - Alois P. Heinz, Aug 01 2020
a(n) is the sum of the largest elements of all subsets of {1,2,..,n}. For example, a(3)=17; the subsets of {1,2,3} are {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}, and the sum of the largest elements is 17. - Enrique Navarrete, Aug 20 2020
a(n-1) is the sum of the second largest elements of the subsets of {1,2,..,n} that contain n. For example, for n = 4, a(3)=17; the subsets of {1,2,3,4} that contain 4 are {4}, {1,4}, {2,4}, {3,4}, {1,2,4}, {1,3,4}, {2,3,4}, {1,2,3,4}, and the sum of the second largest elements is 17. - Enrique Navarrete, Aug 24 2020
a(n-1) is also the sum of diameters of all subsets of {1,2,...,n} that contain n. For example, for n = 4, a(3)=17; the subsets of {1,2,3,4} that contain 4 are {4}, {1,4}, {2,4}, {3,4}, {1,2,4}, {1,3,4}, {2,3,4}, {1,2,3,4}; the diameters of these sets are 0,3,2,1,3,3,2,3 and the sum is 17. - Enrique Navarrete, Sep 07 2020
a(n-1) is also the number of additions required to compute the permanent of general n X n matrices using trellis methods (see Theorems 5 and 6, pp. 10-11 in Kiah et al.). - Stefano Spezia, Nov 02 2021

References

  • F. Harary, Topological concepts in graph theory, pp. 13-17 of F. Harary and L. Beineke, editors, A seminar on Graph Theory, Holt, Rinehart and Winston, New York, 1967.
  • V. G. Gutierrez and S. L. de Medrano, Surfaces as complete intersections, in Riemann and Klein Surfaces, Automorphisms, Symmetries and Moduli Spaces, edited by Milagros Izquierdo, S. Allen Broughton, Antonio F. Costa, Contemp. Math. vol. 629, 2014, pp. 171-.
  • F. Harary, Graph Theory. Addison-Wesley, Reading, MA, 1969, p. 119.
  • G. H. Hardy, A Theorem Concerning the Infinite Cardinal Numbers, Quart. J. Math., 35 (1904), p. 90 = Collected Papers of G. H. Hardy, Vol. VII, p. 430.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

a(n) = T(3, n), array T given by A048472. A036799/2.
Cf. A003338.
Main diagonal of A336725.

Programs

  • GAP
    List([0..30],n->(n-1)*2^n+1); # Muniru A Asiru, Oct 24 2018
  • Magma
    [(n-1)*2^n + 1: n in [0..40]]; // Vincenzo Librandi, Nov 21 2014
    
  • Maple
    A000337 := proc(n) 1+(n-1)*2^n ; end proc: # R. J. Mathar, Oct 10 2011
  • Mathematica
    Table[Sum[(-1)^(n - k) k (-1)^(n - k) Binomial[n + 1, k + 1], {k, 0, n}], {n, 0, 28}] (* Zerinvary Lajos, Jul 08 2009 *)
    Table[(n - 1) 2^n + 1, {n, 0, 40}] (* Harvey P. Dale, Jun 21 2011 *)
    LinearRecurrence[{5, -8, 4}, {0, 1, 5}, 40] (* Harvey P. Dale, Jun 21 2011 *)
    CoefficientList[Series[x / ((1 - x) (1 - 2 x)^2), {x, 0, 50}], x] (* Vincenzo Librandi, Nov 21 2014 *)
  • PARI
    a(n)=if(n<0,0,(n-1)*2^n+1)
    
  • Python
    a=lambda n:((n-1)<<(n))+1 # Indranil Ghosh, Jan 05 2017
    

Formula

Binomial transform of A004273. Binomial transform of A008574 if the leading zero is dropped.
G.f.: x/((1-x)*(1-2*x)^2). - Simon Plouffe in his 1992 dissertation
E.g.f.: exp(x) - exp(2*x)*(1-2*x). a(n) = 4*a(n-1) - 4*a(n-2)+1, n>0. Series reversion of g.f. A(x) is x*A034015(-x). - Michael Somos
Binomial transform of n/(n+1) is a(n)/(n+1). - Paul Barry, Aug 19 2005
a(n) = A119258(n+1,n-1) for n>0. - Reinhard Zumkeller, May 11 2006
Convolution of "Number of fixed points in all 231-avoiding involutions in S_n" (A059570) with "The odd numbers" (A005408), treating the result as if offset=0. - Graeme McRae, Jul 12 2006
a(n) = Sum_{k=1..n} k*2^(k-1), partial sums of A001787. - Zerinvary Lajos, Oct 19 2006
a(n) = 5*a(n-1) - 8*a(n-2) + 4*a(n-3), n > 2. - Harvey P. Dale, Jun 21 2011
a(n) = Sum_{k=1..n} Sum_{i=1..n} i * C(k,i). - Wesley Ivan Hurt, Sep 19 2017
a(n) = A000295(n+1)^2 - A000295(n)*A000295(n+2). - Gregory Gerard Wojnar, Oct 23 2018

A159918 Number of ones in binary representation of n^2.

Original entry on oeis.org

0, 1, 1, 2, 1, 3, 2, 3, 1, 3, 3, 5, 2, 4, 3, 4, 1, 3, 3, 5, 3, 6, 5, 3, 2, 5, 4, 6, 3, 5, 4, 5, 1, 3, 3, 5, 3, 6, 5, 7, 3, 5, 6, 7, 5, 8, 3, 4, 2, 5, 5, 5, 4, 8, 6, 7, 3, 6, 5, 7, 4, 6, 5, 6, 1, 3, 3, 5, 3, 6, 5, 7, 3, 6, 6, 9, 5, 7, 7, 5, 3, 6, 5, 8, 6, 7, 7, 7, 5, 9, 8, 5, 3, 6, 4, 5, 2, 5, 5, 6, 5, 9, 5, 7, 4
Offset: 0

Views

Author

Reinhard Zumkeller, Apr 25 2009

Keywords

Comments

The binary weight (A000120) of n^2.
a(n) = 0 iff n = 0. a(n) = 1 iff n = 2^k for some k >= 0. a(n) = 2 iff n = 3*2^k for some k >= 0. Szalay proves that a(n) = 3 iff n = 7*2^k, 23*2^k, or 2^a + 2^b for k >= 0 and a > b >= 0. It seems that a(n) = 4 iff n = 13*2^k, 15*2^k, 47*2^k, or 111*2^k but this has not been proven! Any other n with a(n) = 4 are greater than 10^50, and there are finitely many odd solutions. - Charles R Greathouse IV, Jan 20 2022

References

  • L. Szalay, The equations 2^n ± 2^m ± 2^l = z^2, Indagationes Mathematicae (N.S.) 13, no. 1 (2002), pp. 131-142.

Crossrefs

Programs

Formula

a(n) = A000120(A000290(n)); a(A077436(n)) = A000120(A077436(n)).
Lindström shows that lim sup wt(m^2)/log_2 m = 2. - N. J. A. Sloane, Oct 11 2013
a(n) = [x^(n^2)] (1/(1 - x))*Sum_{k>=0} x^(2^k)/(1 + x^(2^k)). - Ilya Gutkovskiy, Mar 27 2018

A058369 Numbers k such that k and k^2 have same digit sum.

Original entry on oeis.org

0, 1, 9, 10, 18, 19, 45, 46, 55, 90, 99, 100, 145, 180, 189, 190, 198, 199, 289, 351, 361, 369, 379, 388, 450, 451, 459, 460, 468, 495, 496, 550, 558, 559, 568, 585, 595, 639, 729, 739, 775, 838, 855, 900, 954, 955, 990, 999, 1000, 1098, 1099, 1179, 1188, 1189
Offset: 1

Views

Author

G. L. Honaker, Jr., Dec 17 2000

Keywords

Comments

It is interesting that the graph of this sequence appears almost identical as the maximum value of n increases by factors of 10. Compare the graph of the b-file (having numbers up to 10^6) with the plot of the terms up to 10^8. - T. D. Noe, Apr 28 2012
If iterated digit sum (A010888, A056992) is used instead of just digit sum (A007953, A004159), we get A090570 of which this sequence is a subset. - Jeppe Stig Nielsen, Feb 18 2015
Hare, Laishram, & Stoll show that this sequence (indeed, even its subsequence A254066) is infinite. In particular for each k in {846, 847, 855, 856, 864, 865, 873, ...} there are infinitely many terms in this sequence not divisible by 10 that have digit sum k. - Charles R Greathouse IV, Aug 25 2015
There are infinitely many n such that both n and n+1 are in the sequence. This includes A002283. - Robert Israel, Aug 26 2015

Examples

			Digit sum of 9 = 9 9^2 = 81, 8+1 = 9 digit sum of 145 = 1+4+5 = 10 145^2 = 21025, 2+1+0+2+5 = 10 digit sum of 954 = 9+5+4 = 18 954^2 = 910116, 9+1+0+1+1+6 = 18. - Florian Roeseler (hazz_dollazz(AT)web.de), May 03 2010
		

Crossrefs

Cf. A147523 (number of numbers in each decade).
Subsequence of A090570.

Programs

  • Haskell
    import Data.List (elemIndices)
    import Data.Function (on)
    a058369 n = a058369_list !! (n-1)
    a058369_list =
       elemIndices 0 $ zipWith ((-) `on` a007953) [0..] a000290_list
    -- Reinhard Zumkeller, Aug 17 2011
    
  • Magma
    [n: n in [0..1200] |(&+Intseq(n)) eq (&+Intseq(n^2))]; // Vincenzo Librandi, Aug 26 2015
    
  • Maple
    sd := proc (n) options operator, arrow: add(convert(n, base, 10)[j], j = 1 .. nops(convert(n, base, 10))) end proc: a := proc (n) if sd(n) = sd(n^2) then n else end if end proc; seq(a(n), n = 0 .. 1400); # Emeric Deutsch, May 11 2010
    select(t -> convert(convert(t,base,10),`+`)=convert(convert(t^2,base,10),`+`),
    [seq(seq(9*i+j,j=0..1),i=0..1000)]); # Robert Israel, Aug 26 2015
  • Mathematica
    Select[Range[0,1200],Total[IntegerDigits[#]]==Total[IntegerDigits[ #^2]]&] (* Harvey P. Dale, Jun 14 2011 *)
  • PARI
    is(n)=sumdigits(n)==sumdigits(n^2) \\ Charles R Greathouse IV, Aug 25 2015
    
  • Python
    def ds(n): return sum(map(int, str(n)))
    def ok(n): return ds(n) == ds(n**2)
    def aupto(nn): return [m for m in range(nn+1) if ok(m)]
    print(aupto(1189)) # Michael S. Branicky, Jan 09 2021

Formula

A007953(a(n)) = A004159(a(n)). - Reinhard Zumkeller, Apr 25 2009

Extensions

Edited by N. J. A. Sloane, May 30 2010

A094694 Numbers having in binary representation more 1s than their squares.

Original entry on oeis.org

23, 46, 47, 92, 94, 95, 111, 184, 188, 190, 191, 222, 223, 367, 368, 376, 380, 382, 383, 415, 444, 446, 447, 479, 727, 734, 736, 752, 760, 764, 766, 767, 830, 831, 887, 888, 892, 894, 895, 958, 959, 1451, 1454, 1468, 1471, 1472, 1503, 1504, 1520, 1528
Offset: 1

Views

Author

Reinhard Zumkeller, May 20 2004

Keywords

Comments

A000120(a(n)) > A000120(A000290(a(n))).

Crossrefs

Programs

  • Mathematica
    Select[Range[1600], DigitCount[#, 2, 1] > DigitCount[#^2, 2, 1] &] (* Harvey P. Dale, Mar 24 2012 *)
  • PARI
    is(n)=hammingweight(n)>hammingweight(n^2) \\ Charles R Greathouse IV, Jan 27 2014
    
  • Python
    print([k for k in range(0, 1530) if bin(k)[2:].count("1") > bin(k**2)[2:].count("1")]) # Karl-Heinz Hofmann, Feb 07 2022

A083567 Let B(k) be the number of binary digits in k equal to 1. This is the sequence of positive integers k such that 2B(k)=B(k^2).

Original entry on oeis.org

21, 37, 42, 45, 53, 69, 73, 74, 81, 83, 84, 90, 106, 133, 137, 138, 141, 146, 148, 155, 161, 162, 165, 166, 168, 177, 180, 211, 212, 261, 265, 266, 269, 273, 274, 276, 281, 282, 289, 291, 292, 295, 296, 299, 310, 321, 322, 324, 330, 332, 336, 354, 359, 360
Offset: 1

Views

Author

Giuseppe Melfi, Jun 13 2003

Keywords

Comments

This includes all k > 1 such that the average of ones in the binary expansion of k is the same of the average of ones in binary expansion of k^2; these are the values in the sequence with sqrt(2)*2^j < a(k) < 2^(j+1) for some j. - Corrected by Franklin T. Adams-Watters, Aug 23 2012
Conjecture: The counting function p(n) satisfies p(n)=c n/log n + o(n/log n).

Examples

			21 is in the sequence because 21=10101_2 (3 1's) and 441=110111001_2 (6 1's).
		

Crossrefs

Programs

  • Maple
    select(t -> 2*convert(convert(t,base,2),`+`) = convert(convert(t^2,base,2),`+`), [$1..1000]); # Robert Israel, Aug 27 2015
  • Mathematica
    f[n_] := Total@ IntegerDigits[n, 2]; Select[Range@ 360, 2 f@ # == f[#^2] &] (* Michael De Vlieger, Aug 27 2015 *)
  • PARI
    isok(n) =  norml2(binary(n^2)) == 2*norml2(binary(n)) \\ Michel Marcus, Jun 20 2013

A277704 Positions of squares in A277699.

Original entry on oeis.org

1, 2, 3, 4, 6, 7, 8, 12, 14, 15, 16, 24, 28, 30, 31, 32, 48, 56, 60, 62, 63, 64, 83, 96, 112, 120, 124, 126, 127, 128, 166, 192, 224, 240, 248, 252, 254, 255, 256, 332, 365, 384, 448, 480, 496, 504, 508, 510, 511, 512, 664, 730, 768, 896, 960, 992, 1008, 1016, 1020, 1022, 1023, 1024, 1328, 1460, 1536, 1792, 1920, 1984, 2016
Offset: 1

Views

Author

Antti Karttunen, Nov 01 2016

Keywords

Crossrefs

Complement: A277706.
Cf. A023758 (a subsequence), A277807 (terms not in A023758).
Differs from A023758(1+n) and A077436(1+n) for the first time at n=23, for which a(23)=83, while A023758(24)=96 and A077436(24)=79.

A340069 a(n) is the smallest number k not yet used such that the number of 1-bits in the binary representation of k equals the number of 1-bits in the binary representation of k*n.

Original entry on oeis.org

0, 1, 2, 3, 4, 7, 6, 14, 5, 15, 27, 12, 24, 10, 19, 30, 8, 31, 43, 28, 39, 13, 35, 45, 48, 62, 20, 57, 37, 63, 60, 79, 9, 126, 91, 11, 86, 29, 56, 23, 54, 75, 26, 51, 70, 46, 47, 22, 89, 21, 93, 83, 40, 61, 114, 78, 38, 18, 71, 87, 77, 42, 124, 127, 16, 254, 187, 92, 151, 90, 44, 58, 117
Offset: 0

Views

Author

Thomas Scheuerle, Dec 28 2020

Keywords

Comments

I would call this sequence "the evil beast" because it shows many patterns, but for each pattern there seems to be a value of n at which the rules change suddenly or some unexpected exceptions occur.
If n is a power of 2 any number satisfies the condition as the number of 1-bits does not change by multiplication by a power of 2. Because of this every number eventually has a chance to appear in this sequence; this proves that this sequence is a permutation of the nonnegative integers.
This sequence may have applications in finding small pairs of b and c such that A000120(b)=A000120(c*b), because A000120(a(n))=A000120(a(n)*n).
All fixed points n = a(n) are described in A340100 and are a subset of A077436.
In the range n = 0..100000 the largest value a(n) is 131072 = a(32769), but the smallest value in the range n = 30000..40000 is a(32768) = 137.
If A000120(b)=A000120(c*b) then A000120(b*2^d)=A000120(c*b*2^d); this causes some patterns in this sequence which may be valid in a limited range of n. Can we find one which is valid for a large range of values of n?
If a(n) is a power of two, then n is a power of two as well. But if n is a power of two, a(n) is not always a power of two.
In equations of the form A000120(c)=A000120(c*b) for all A000120(c)=2 we find all solutions for b as b=0, b=2^d or b=(2^d)*(1+2^(((c-1)/2)+e*(c-1)))/c, if c is odd. For even c divide c by largest possible power of two. An example for c=3 is b=A263132.
a(n) >= A292849(n). This lower bound is responsible for some of the peaks in this sequence.

Crossrefs

Cf. A000120, A077436, A340100, A263132 (numbers such that A000120(3)=A000120(3*m)), A077459 (numbers such that A000120(m)=A000120(3*m)), A292849 (the least m such that A000120(n*m) = A000120(m)), A340351.

Programs

  • MATLAB
    function a = A340069( max_n )
        a(1) = 1;
        n = 2;
        t = 1;
        while n <= max_n
            % search next number t not yet used in a
            while ~isempty(find(a==t, 1))
                t = t+1;
            end
            bits1 = length(find(bitget(t,1:32)== 1));
            bits2 = length(find(bitget(t*n,1:32)== 1));
            if (bits1 == bits2)
                % we found a candidate
                a(n) = t;
                t = 1;
                n = n+1;
            else
                % number t does not yet fit
                t = t+1;
            end
        end
    end
    
  • PARI
    lista(nn) = {my(va = vector(nn, k, -1)); for (n=0, nn-1, my(k=0); while(! ((hammingweight(k*n) == hammingweight(k)) && !(#select(x->(x==k), va))), k++); va[n+1] = k;); va;} \\ Michel Marcus, Dec 30 2020
    
  • Python
    def binwt(n): return bin(n).count('1')
    def aupto(n):
      alst, aset = [], set()
      for k in range(n+1):
        ak = 0
        while True:
          while ak in aset: ak += 1
          if binwt(ak)==binwt(k*ak): break
          ak += 1
        alst.append(ak)
        aset.add(ak)
      return alst
    print(aupto(72)) # Michael S. Branicky, Jan 02 2021

Formula

a(n) = n if n < 5.
a(2^(2*n)) = 2^(1+n) if n < 5.
a(2^(2*n+1)) = 2^(1+n)+1 if n < 5.
a(3*2^n) = 3*2^(n+1) if n > 0 and < 4.
Showing 1-10 of 28 results. Next