|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,3
|
|
LINKS
|
|
|
FORMULA
|
|
|
MAPLE
|
q:= n-> (f-> is(f(n, 10)<=f(n, 2)))((x, b)
-> add(i, i=convert(x, base, b))):
|
|
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')
(PARI) isok(n) = sumdigits(n, 10) <= sumdigits(n, 2); \\ Michel Marcus, Sep 07 2019
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|