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

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

A231897 a(n) = smallest m such that wt(m^2) = n (where wt(i) = A000120(i)), or -1 if no such m exists.

Original entry on oeis.org

0, 1, 3, 5, 13, 11, 21, 39, 45, 75, 155, 217, 331, 181, 627, 923, 1241, 2505, 3915, 5221, 6475, 11309, 15595, 19637, 31595, 44491, 69451, 113447, 185269, 244661, 357081, 453677, 1015143, 908091, 980853, 2960011, 4568757, 2965685, 5931189, 11862197, 20437147
Offset: 0

Views

Author

N. J. A. Sloane, Nov 19 2013

Keywords

Comments

Conjecture: a(n) is never -1. (It seems likely that the arguments of Lindström (1997) could be modified to establish this conjecture.)
a(n) is the smallest m such that A159918(m) = n (or -1 if ...).

Crossrefs

A089998 are the corresponding squares.

Programs

  • Haskell
    a231897 n = head [x | x <- [1..], a159918 x == n]
    -- Reinhard Zumkeller, Nov 20 2013
    
  • PARI
    a(n)=if(n,my(k); while(hammingweight(k++^2)!=n,); k, 0) \\ Charles R Greathouse IV, Aug 06 2015
    
  • Python
    def wt(n): return bin(n).count('1')
    def a(n):
        m = 2**(n//2) - 1
        while wt(m**2) != n: m += 1
        return m
    print([a(n) for n in range(32)]) # Michael S. Branicky, Feb 06 2022

Formula

a(n) = 2*A211201(n-1) + 1 for n >= 1. - Hugo Pfoertner, Feb 06 2022

Extensions

a(26)-a(40) from Reinhard Zumkeller, Nov 20 2013

A214560 Number of 0's in binary expansion of n^2.

Original entry on oeis.org

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

Views

Author

Alex Ratushnyak, Jul 21 2012

Keywords

Comments

Conjecture: for every x>=0 there is an i such that a(n)>x for n>i.
Comment from N. J. A. Sloane, Nov 21 2013: See also the conjecture in A231898.

Crossrefs

Programs

  • Haskell
    a214560 = a023416 . a000290  -- Reinhard Zumkeller, Nov 20 2013
    
  • Maple
    A214560 := proc(n)
        A023416(n^2) ;
    end proc: # R. J. Mathar, Jul 21 2012
    # second Maple program:
    a:= n-> `if`(n=0, 1, add(1-i, i=Bits[Split](n^2))):
    seq(a(n), n=0..84);  # Alois P. Heinz, Nov 25 2024
  • Mathematica
    Join[{1},Table[DigitCount[n^2,2,0],{n,100}]] (* Harvey P. Dale, Nov 24 2024 *)
  • PARI
    vector(66,n,b=binary((n-1)^2);sum(j=1,#b,1-b[j])) /* Joerg Arndt, Jul 21 2012 */
    
  • Python
    for n in range(300):
        b = n*n
        c = 0
        while b>0:
            c += 1-(b&1)
            b//=2
        print(c+(n==0), end=', ')
    
  • Python
    def A214560(n):
        return bin(n*n)[2:].count('0') # Chai Wah Wu, Sep 03 2014

Formula

a(n) = A023416(A000290(n)).

A232243 a(n) = wt(n^2) - wt(n), where wt(n) = A000120(n) is the binary weight function.

Original entry on oeis.org

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

Views

Author

Jon Perry, Nov 20 2013

Keywords

Comments

A077436 lists n for which a(n) = 0.
A094694 lists n for which a(n) < 0.

Examples

			a(5): 5 = 101_2, 25 = 11001_2, so a(5) = 3 - 2 = 1.
a(23): 23 = 10111_2, 529 = 10001001_2, so a(23) = 3 - 4 = -1.
		

Crossrefs

Programs

  • JavaScript
    function bitCount(n) {
       var i,c,s;
       c=0;
       s=n.toString(2);
       for (i=0;i
    				
  • PARI
    a(n) = hammingweight(n^2) - hammingweight(n); \\ Michel Marcus, Mar 05 2023
  • Python
    def A232243(n): return (n**2).bit_count()-n.bit_count()
    print(list(A232243(n) for n in range(10**2)))  # Dumitru Damian, Mar 04 2023
    

Formula

a(n) = A159918(n) - A000120(n).

A232245 Sum of the number of ones in binary representation of n and n^2.

Original entry on oeis.org

0, 2, 2, 4, 2, 5, 4, 6, 2, 5, 5, 8, 4, 7, 6, 8, 2, 5, 5, 8, 5, 9, 8, 7, 4, 8, 7, 10, 6, 9, 8, 10, 2, 5, 5, 8, 5, 9, 8, 11, 5, 8, 9, 11, 8, 12, 7, 9, 4, 8, 8, 9, 7, 12, 10, 12, 6, 10, 9, 12, 8, 11, 10, 12, 2, 5, 5, 8, 5, 9, 8, 11, 5, 9, 9, 13, 8, 11, 11, 10, 5, 9
Offset: 0

Views

Author

Jon Perry, Nov 20 2013

Keywords

Comments

The sequence is never 1 or 3, but seems to take on all other values. The fact it is never 3 can be used to prove if n^2 has exactly 4 1's then it must have an even number of 0's (A231898).

Examples

			5 is 101 and 25 is 11001, so a(5) = 2 + 3 = 5.
		

Crossrefs

Programs

  • JavaScript
    function bitCount(n) {
    var i,c,s;
    c=0;
    s=n.toString(2);
    for (i=0;i
    				

Formula

a(n) = A159918(n) + A000120(n).
Showing 1-5 of 5 results.