OFFSET
0,2
LINKS
Amiram Eldar, Table of n, a(n) for n = 0..10000
FORMULA
a(n) = A005187(n) + n mod 2.
a(n) ~ 2*n. - Amiram Eldar, Aug 30 2024
MAPLE
MATHEMATICA
a[n_] := 2*n + Mod[n, 2] - DigitCount[2*n, 2, 1]; Array[a, 100, 0] (* Amiram Eldar, Aug 30 2024 *)
PROG
(SageMath)
@cached_function
def A327492(n):
if n == 0: return 0
r = valuation(n, 2) if 4.divides(n) else n % 2 + 1
return r + A327492(n-1)
print([A327492(n) for n in (0..19)])
(PARI) seq(n)={my(a=vector(n+1)); for(n=1, n, a[n+1] = a[n] + if(n%4, n%2 + 1, valuation(n, 2))); a} \\ Andrew Howroyd, Sep 28 2019
(PARI) a(n) = n<<1 - hammingweight(n) + bittest(n, 0); \\ Kevin Ryde, May 31 2022
(Julia)
bitcount(n) = sum(digits(n, base = 2))
A327492(n) = 2n - bitcount(n) + mod(n, 2)
[A327492(n) for n in 0:62] |> println # Peter Luschny, Oct 03 2019
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Peter Luschny, Sep 27 2019
STATUS
approved