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.

A077436 Let B(n) be the sum of binary digits of n. This sequence contains n such that B(n) = B(n^2).

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, 79, 91, 96, 112, 120, 124, 126, 127, 128, 157, 158, 159, 182, 183, 187, 192, 224, 240, 248, 252, 254, 255, 256, 279, 287, 314, 316, 317, 318, 319, 351, 364, 365, 366, 374, 375, 379, 384
Offset: 1

Views

Author

Giuseppe Melfi, Nov 30 2002

Keywords

Comments

Superset of A023758.
Hare, Laishram, & Stoll show that this sequence contains infinitely many odd numbers. In particular for each k in {12, 13, 16, 17, 18, 19, 20, ...} there are infinitely many terms in this sequence with binary digit sum k. - Charles R Greathouse IV, Aug 25 2015

Examples

			The element 79 belongs to the sequence because 79=(1001111) and 79^2=(1100001100001), so B(79)=B(79^2)
		

Crossrefs

Cf. A211676 (number of n-bit numbers in this sequence).
A261586 is a subsequence. Subsequence of A352084.

Programs

  • Haskell
    import Data.List (elemIndices)
    import Data.Function (on)
    a077436 n = a077436_list !! (n-1)
    a077436_list = elemIndices 0
       $ zipWith ((-) `on` a000120) [0..] a000290_list
    -- Reinhard Zumkeller, Apr 12 2011
    
  • Magma
    [n: n in [0..400] | &+Intseq(n, 2) eq &+Intseq(n^2, 2)]; // Vincenzo Librandi, Aug 30 2015
    
  • Maple
    select(t -> convert(convert(t,base,2),`+`) = convert(convert(t^2,base,2),`+`), [$0..1000]); # Robert Israel, Aug 27 2015
  • Mathematica
    t={}; Do[If[DigitCount[n, 2, 1] == DigitCount[n^2, 2, 1], AppendTo[t, n]], {n, 0, 364}]; t
    f[n_] := Total@ IntegerDigits[n, 2]; Select[Range[0, 384], f@ # == f[#^2] &] (* Michael De Vlieger, Aug 27 2015 *)
  • PARI
    is(n)=hammingweight(n)==hammingweight(n^2) \\ Charles R Greathouse IV, Aug 25 2015
    
  • Python
    def ok(n): return bin(n).count('1') == bin(n**2).count('1')
    print([m for m in range(400) if ok(m)]) # Michael S. Branicky, Mar 11 2022

Formula

A159918(a(n)) = A000120(a(n)). - Reinhard Zumkeller, Apr 25 2009

Extensions

Initial 0 added by Reinhard Zumkeller, Apr 28 2012, Apr 12 2011

A261593 Odd numbers n such that the sum of the binary digits of n and n^2 both equal 12.

Original entry on oeis.org

4095, 10239, 11263, 12159, 12223, 12255, 12271, 12279, 12283, 14333, 15351, 15355, 15743, 15807, 18431, 19455, 19967, 20351, 20477, 22015, 22495, 22511, 24031, 24303, 24431, 24445, 25599, 26615, 26621, 27519, 27631, 27639, 28095, 28411, 28413, 28511, 28541, 28575
Offset: 1

Views

Author

Keywords

Comments

Hare, Laishram, & Stoll show that this sequence is infinite.
12 is the least constant for which the associated sequence is known to be infinite. 1 through 8 make finite sequences, the sequences with 9 and 10 are conjectured finite, and the sequence with 11 is unknown. (See Hare-Laishram-Stoll Theorem 1.3 and 1.4 plus section 5.)
Odd numbers n such that the sum of the binary digits of n-1 and n^2-1 both equal 11. - Chai Wah Wu, Aug 26 2015

Examples

			4095 = 111111111111_2 and 4095^2 = 111111111110000000000001_2 both have 12 1s in binary.
		

Crossrefs

Subsequence of A261586 and hence of A077436.

Programs

  • Mathematica
    Select[2 Range@ 15000 - 1, Total@ IntegerDigits[#, 2] == 12 && Total@ IntegerDigits[#^2, 2] == 12 &] (* Michael De Vlieger, Aug 27 2015 *)
  • PARI
    is(n)=n%2 && hammingweight(n)==12 && hammingweight(n^2)==12
    
  • PARI
    \\ List the elements below 2^(N+1).
    go(N)=my(v=List(),n); forvec(u=vector(11,i,[1,N-11+i]), n=sum(i=1,11,2^u[i])+1; if(hammingweight(n^2)==12, listput(v,n)), 2); Set(v)
    
  • Python
    from itertools import combinations
    A261593_list = []
    for c in combinations((2**x for x in range(15)),11):
        n = sum(c)
        if sum(int(d) for d in format(n*(n+1),'b')) == 11:
            A261593_list.append(2*n+1)
    A261593_list = sorted(A261593_list) # Chai Wah Wu, Aug 26 2015
Showing 1-2 of 2 results.