STATUS
proposed
approved
proposed
approved
editing
proposed
return c # Chai Wah Wu, Sep 19 2023
(Python)
def A065620(n):
c, a, b = 0, -1, 1
for j in bin(n)[-1:1:-1]:
if int(j):
c += (a:=-a)*b
b <<= 1
return c # Chai Wah Wu, Sep 19 2023
approved
editing
reviewed
approved
proposed
reviewed
editing
proposed
D. Donald E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1969, Vol. 2, p. 178, (exercise 4.1. Nr. 27).
11 = 1 + 2 + 8 -> 1 - 2 + 8 = 7 = a(11).
a[0] = 0; a[n_]:= a[n]= If[OddQ[n], 1 - 2*a[(n-1)/2], 2*a[n/2]]; Array[a, 100, 0] (* Amiram Eldar, Sep 05 2023 *)
approved
editing
editing
approved