login
A327492
Partial sums of A327491.
7
0, 2, 3, 5, 7, 9, 10, 12, 15, 17, 18, 20, 22, 24, 25, 27, 31, 33, 34, 36, 38, 40, 41, 43, 46, 48, 49, 51, 53, 55, 56, 58, 63, 65, 66, 68, 70, 72, 73, 75, 78, 80, 81, 83, 85, 87, 88, 90, 94, 96, 97, 99, 101, 103, 104, 106, 109, 111, 112, 114, 116, 118, 119
OFFSET
0,2
LINKS
FORMULA
a(n) = A005187(n) + n mod 2.
a(n) ~ 2*n. - Amiram Eldar, Aug 30 2024
MAPLE
# For len >= 1:
A327492_list := len -> ListTools:-PartialSums([seq(A327491(j), j=0..len-1)]):
A327492_list(99)
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