A364834 Sum of positive integers <= n which are multiples of 2 or 5.
0, 2, 2, 6, 11, 17, 17, 25, 25, 35, 35, 47, 47, 61, 76, 92, 92, 110, 110, 130, 130, 152, 152, 176, 201, 227, 227, 255, 255, 285, 285, 317, 317, 351, 386, 422, 422, 460, 460, 500, 500, 542, 542, 586, 631, 677, 677, 725, 725, 775, 775, 827, 827, 881, 936
Offset: 1
Links
- Index entries for linear recurrences with constant coefficients, signature (1,0,0,0,0,0,0,0,0,2,-2,0,0,0,0,0,0,0,0,-1,1).
Programs
-
Mathematica
Accumulate[Table[n * Boole[MemberQ[Mod[n, {2, 5}], 0]], {n, 0, 55}]] (* Amiram Eldar, Aug 09 2023 *)
-
PARI
a(n) = vecsum(select(x->(!(x%2) || !(x%5)), [1..n])); \\ Michel Marcus, Aug 09 2023
-
Python
sn = lambda k, n: ((n // k)*((n // k) + 1) * k) // 2 a = lambda n: sn(2, n) + sn(5, n) - sn(10, n) print([a(n) for n in range(1, 56)])
Formula
a(n) = sn(n,2) + sn(n,5) - sn(n,10) where sn(n,d) = (an(n,d) * (an(n,d) + d))/(2*d) and an(n,d) = d * floor(n/d).
a(n) = Sum_{k=2..n} {k if gcd(k,10) > 1}.
Comments