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

A164344 Positive integers whose square contains the same number of 0's as 1's when represented in binary.

Original entry on oeis.org

3, 7, 13, 15, 25, 29, 31, 54, 57, 61, 63, 103, 110, 113, 118, 121, 125, 127, 199, 203, 207, 212, 213, 214, 218, 230, 238, 241, 246, 249, 253, 255, 389, 393, 394, 395, 402, 404, 409, 421, 431, 433, 435, 439, 458, 468, 478, 481, 486, 494, 497, 502, 505, 509, 511
Offset: 1

Views

Author

Leroy Quet, Aug 13 2009

Keywords

Comments

The squares must have an even number of binary digits, given by ceiling(log_2(a(n)^2)) = ceiling(2 log_2 a(n)), or equivalently, 2^(k-1/2) < a(n) < 2^k for some integer k > 0, which explains the jumps in the graph of the sequence. - M. F. Hasler, Jul 12 2022

Crossrefs

Cf. A031443 (digitally balanced numbers), A164343 (squares of the terms), A000120 (Hamming weight), A070939 (number of binary digits).

Programs

  • Mathematica
    sn01Q[n_]:=Module[{idn2=IntegerDigits[n^2,2]},Count[idn2,1] == Length[ idn2]/2]; Select[Range[600],sn01Q] (* Harvey P. Dale, Apr 03 2016 *)
  • PARI
    select( {is_A164344(n)=hammingweight(n^2)*2==exponent(n^2*2)}, [0..512]) \\ M. F. Hasler, Jul 12 2022
    
  • Python
    def bal(n): return n and n.bit_length() == n.bit_count() * 2
    print([k for k in range(512) if bal(k*k)]) # Michael S. Branicky, Jul 12 2022

Formula

{n | n^2 is in A031443} = {n | 2*A000120(n^2) = A070939(n^2)}, i.e., twice the Hamming weight must equal the number of binary digits, for the squares of the terms. - M. F. Hasler, Jul 12 2022

Extensions

More terms from Sean A. Irvine, Oct 08 2009

A356878 a(n) is the least number of binary zeros of squares with binary weight n.

Original entry on oeis.org

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

Views

Author

Karl-Heinz Hofmann, Sep 30 2022

Keywords

Examples

			    Squares with    |             possible number of zeros
    binary weight   |  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 ...
         n          |            the leftmost value is a(n)
   -----------------+----------------------------------------------------
         0          |  -  1  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
         1          |  0  -  2  -  4  -  6  -  8  - 10  - 12  - 14  - ...
         2          |  -  -  2  -  4  -  6  -  8  - 10  - 12  - 14  - ...
         3          |  -  -  2  3  4  5  6  7  8  9 10 11 12 13 14 15 ...
         4          |  -  -  -  -  4  -  6  -  8  - 10  - 12  - 14  - ...
         5          |  -  -  2  -  4  5  6  7  8  9 10 11 12 13 14 15 ...
         6          |  -  -  -  3  4  5  6  7  8  9 10 11 12 13 14 15 ...
         7          |  -  -  -  -  4  5  6  7  8  9 10 11 12 13 14 15 ...
         8          |  -  -  -  3  4  5  6  7  8  9 10 11 12 13 14 15 ...
         9          |  -  -  -  -  4  5  6  7  8  9 10 11 12 13 14 15 ...
        10          |  -  -  -  -  -  5  6  7  8  9 10 11 12 13 14 15 ...
        11          |  -  -  -  -  -  5  6  7  8  9 10 11 12 13 14 15 ...
        12          |  -  -  -  -  -  5  6  7  8  9 10 11 12 13 14 15 ...
        13          |  -  -  2  -  4  -  6  7  8  9 10 11 12 13 14 15 ...
        14          |  -  -  -  -  -  5  6  7  8  9 10 11 12 13 14 15 ...
         :          |  ...
		

Crossrefs

A357750 a(n) is the least k such that B(k^2) - B(k) = n, where B(m) is the binary weight A000120(m).

Original entry on oeis.org

0, 5, 11, 21, 45, 75, 217, 331, 181, 789, 1241, 2505, 5701, 5221, 11309, 19637, 43151, 69451, 82709, 166027, 346389, 607307, 689685, 1458357, 1380917, 2507541, 5906699, 2965685, 5931189, 11862197, 47448787, 82188309, 57804981, 94905541, 188883211, 373457573, 640164021
Offset: 0

Views

Author

Keywords

Examples

			  ----------------------------------------------------
  n     k      k^2     binary k             binary k^2
  ----------------------------------------------------
  0     0        0            0                      0
  1     5       25          101                  11001
  2    11      121         1011                1111001
  3    21      441        10101              110111001
  4    45     2025       101101            11111101001
  5    75     5625      1001011          1010111111001
  6   217    47089     11011001       1011011111110001
  7   331   109561    101001011      11010101111111001
  8   181    32761     10110101        111111111111001
  9   789   622521   1100010101   10010111111110111001
		

Crossrefs

Programs

  • PARI
    a(n) = my(k=0); while(hammingweight(k^2) - hammingweight(k) != n, k++); k;
    
  • Python
    from itertools import count
    def A357750(n):
        for k in count(0):
            if (k**2).bit_count()-k.bit_count()==n:
                return k # Chai Wah Wu, Oct 17 2022

A345348 Triangular numbers that in base 2 have the same number of 0's and 1's.

Original entry on oeis.org

10, 153, 210, 595, 666, 820, 2278, 2701, 9045, 9870, 10585, 11476, 12403, 13366, 13861, 14365, 34191, 34716, 35245, 36046, 37675, 37950, 39340, 39621, 40470, 41905, 42195, 42778, 43365, 44551, 45150, 45451, 46665, 48516, 49455, 50086, 50403, 51681, 52003, 52326
Offset: 1

Views

Author

Ctibor O. Zizka, Jun 15 2021

Keywords

Examples

			Triangular number 153 = '10011001' in binary, the number of 1's equals the number of 0's, so 153 is a term.
		

Crossrefs

Intersection of A000217 and A031443.
Cf. A164343.

Programs

  • Mathematica
    Select[Table[n*(n + 1)/2, {n, 0, 330}], Equal @@ DigitCount[#, 2] &] (* Amiram Eldar, Jun 15 2021 *)
  • PARI
    isA031443(n)=2*hammingweight(n)==exponent(n)+1
    list(lim)=my(v=List(),n=4,t); while((t=n*n++/2)<=lim, if(isA031443(t), listput(v,t))); Vec(v) \\ Charles R Greathouse IV, Jun 21 2021
    
  • Python
    A345348_list = [n for n in (m*(m+1)//2 for m in range(10**6)) if len(bin(n))-2 == 2*bin(n).count('1')] # Chai Wah Wu, Jun 21 2021

Extensions

More terms from Jinyuan Wang, Jun 15 2021
Showing 1-4 of 4 results.