login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A325483
Numbers whose sum of their decimal digits is less than or equal to the sum of the digits of their binary representation.
2
0, 1, 10, 11, 20, 21, 30, 31, 100, 101, 102, 103, 110, 111, 120, 121, 122, 123, 200, 201, 202, 203, 210, 211, 220, 221, 222, 223, 230, 231, 300, 301, 302, 303, 310, 311, 410, 411, 500, 501, 502, 503, 510, 511, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007
OFFSET
1,3
LINKS
FORMULA
{ A037308 } union { A108580 }.
MAPLE
q:= n-> (f-> is(f(n, 10)<=f(n, 2)))((x, b)
-> add(i, i=convert(x, base, b))):
select(q, [$0..1500])[]; # Alois P. Heinz, Sep 06 2019
MATHEMATICA
Select[Range[0, 1007], Total[IntegerDigits[#]]<=Total[IntegerDigits[#, 2]]&] (* Metin Sariyar, Sep 14 2019 *)
PROG
(Python)
x=0
#Adjust the inequality below to generate more numbers of the sequence
while(x<100):
x = x+1
Number = int(bin(x)[2:])
Bin_Sum = 0
while(Number > 0):
Reminder = Number % 10
Bin_Sum = Bin_Sum + Reminder
Number = Number //10
Number = x
Sum = 0
while(Number > 0):
Reminder = Number % 10
Sum = Sum + Reminder
Number = Number //10
if (Sum <= Bin_Sum):
print(x)
(Python)
def ok(n): return sum(map(int, str(n))) <= bin(n).count('1')
print(list(filter(ok, range(1008)))) # Michael S. Branicky, Oct 11 2021
(PARI) isok(n) = sumdigits(n, 10) <= sumdigits(n, 2); \\ Michel Marcus, Sep 07 2019
CROSSREFS
Supersequence of A037308 and A108580.
Sequence in context: A352339 A197652 A261909 * A235202 A049345 A007623
KEYWORD
nonn,base
AUTHOR
STATUS
approved