A325483 Numbers whose sum of their decimal digits is less than or equal to the sum of the digits of their binary representation.
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
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..10000
Programs
-
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 *)
-
PARI
isok(n) = sumdigits(n, 10) <= sumdigits(n, 2); \\ Michel Marcus, Sep 07 2019
-
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