OFFSET
1,3
COMMENTS
n is in the sequence iff n+(-1)^n is in the sequence. [Robert Israel, Mar 25 2013]
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
FORMULA
From Reinhard Zumkeller, Aug 06 2010: (Start)
A180018(a(n)) = 0. (End)
EXAMPLE
122 is a member, since digital-sum_2(122) = 5 = digital-sum_10(122).
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 *)
PROG
(PARI) is(n)=hammingweight(n)==sumdigits(n); \\ Charles R Greathouse IV, Sep 25 2012
(Sage) [n for n in (0..10000) if sum(n.digits(base=2)) == sum(n.digits(base=10))] # Freddy Barrera, Oct 12 2018
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
Edited by N. J. A. Sloane Nov 29 2008 at the suggestion of Zak Seidov
STATUS
approved