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.

A037308 Numbers whose base-2 and base-10 expansions have the same digit sum.

Original entry on oeis.org

0, 1, 20, 21, 122, 123, 202, 203, 222, 223, 230, 231, 302, 303, 410, 411, 502, 503, 1130, 1131, 1150, 1151, 1202, 1203, 1212, 1213, 1230, 1231, 1300, 1301, 1402, 1403, 1502, 1503, 1510, 1511, 2006, 2007, 2032, 2033, 2102, 2103, 2200, 2201, 3006, 3007, 3012
Offset: 1

Views

Author

Keywords

Comments

n is in the sequence iff n+(-1)^n is in the sequence. [Robert Israel, Mar 25 2013]

Examples

			122 is a member, since digital-sum_2(122) = 5 = digital-sum_10(122).
		

Crossrefs

Programs

  • Maple
    N:= 10000; # to get all elements up to N
    select(x -> (convert(convert(x,base,10),`+`)-convert(convert(x,base,2),`+`)=0), [$0..N]); # Robert Israel, Mar 25 2013
  • Mathematica
    Select[Range[0, 5000], Total[IntegerDigits[#, 2]] == Total[IntegerDigits[#, 10]] &] (* Jean-François Alcover, Mar 07 2016 *)
  • PARI
    is(n)=hammingweight(n)==sumdigits(n); \\ Charles R Greathouse IV, Sep 25 2012
    
  • Python
    def ok(n): return sum(map(int, str(n))) == sum(map(int, bin(n)[2:]))
    print(list(filter(ok, range(3013)))) # Michael S. Branicky, Jun 20 2021
  • Sage
    [n for n in (0..10000) if sum(n.digits(base=2)) == sum(n.digits(base=10))] # Freddy Barrera, Oct 12 2018
    

Formula

From Reinhard Zumkeller, Aug 06 2010: (Start)
A007953(a(n)) = A000120(a(n));
A180018(a(n)) = 0. (End)

Extensions

Edited by N. J. A. Sloane Nov 29 2008 at the suggestion of Zak Seidov