[go: up one dir, main page]

login
A283981
a(n) = A029931(n) - A280700(n).
2
0, 0, 0, 2, 0, 3, 3, 3, 0, 4, 4, 4, 4, 4, 6, 7, 0, 5, 5, 5, 5, 5, 7, 8, 5, 5, 8, 9, 8, 9, 11, 11, 0, 6, 6, 6, 6, 6, 8, 9, 6, 6, 9, 10, 9, 10, 12, 12, 6, 6, 10, 11, 10, 11, 13, 13, 10, 11, 14, 14, 14, 14, 14, 17, 0, 7, 7, 7, 7, 7, 9, 10, 7, 7, 10, 11, 10, 11, 13, 13, 7, 7, 11, 12, 11, 12, 14, 14, 11, 12, 15, 15, 15, 15, 15, 18, 7, 7, 12, 13, 12, 13, 15, 15, 12
OFFSET
0,4
FORMULA
a(n) = A029931(n) - A280700(n).
a(n) = A283982(n) + A124757(n).
MATHEMATICA
Table[#.Reverse@ Range@ Length@ # &@ IntegerDigits[n, 2] - DigitCount[2 n - DigitCount[2 n, 2, 1], 2, 1], {n, 0, 120}] (* Michael De Vlieger, Mar 20 2017, after Jean-François Alcover at A029931 *)
PROG
(Scheme) (define (A283981 n) (- (A029931 n) (A280700 n)))
(PARI)
a(n) = if(n<1, 0, a(n - 2^logint(n, 2)) + logint(n, 2) + 1);
b(n) = if(n<1, 0, b(n\2) + n%2);
A(n) = b(2*n - b(2*n));
for(n=0, 150, print1(a(n) - A(n), ", ")) \\ Indranil Ghosh, Mar 21 2017
(Python)
import math
def L(n): return int(math.floor(math.log(n, 2)))
def a(n): return 0 if n<1 else a(n - 2**L(n)) + L(n) + 1
def A(n): return bin(2*n - bin(2*n)[2:].count("1"))[2:].count("1")
print([a(n) - A(n) for n in range(151)]) # Indranil Ghosh, Mar 21 2017
KEYWORD
nonn,base,look
AUTHOR
Antti Karttunen, Mar 19 2017
STATUS
approved