login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A108174 Partial sums of the positive integers n according to the rule: if n is square then subtract n, otherwise add n. 1
0, -1, 1, 4, 0, 5, 11, 18, 26, 17, 27, 38, 50, 63, 77, 92, 76, 93, 111, 130, 150, 171, 193, 216, 240, 215, 241, 268, 296, 325, 355, 386, 418, 451, 485, 520, 484, 521, 559, 598, 638, 679, 721, 764, 808, 853, 899, 946, 994, 945, 995, 1046, 1098, 1151, 1205, 1260, 1316, 1373, 1431, 1490, 1550, 1611, 1673, 1736, 1672 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,4
LINKS
FORMULA
a(n) = Sum_{i=1..n} i*(-1)^tau(i), where tau(i) = A000005(i). - Ridouane Oudra, Oct 08 2019
a(n) = (1/6)*(3*n^2 + 3*n - 2*floor(sqrt(n)) - 6*floor(sqrt(n))^2 - 4*floor(sqrt(n))^3). - Ridouane Oudra, Aug 22 2021
MATHEMATICA
Accumulate[Table[If[IntegerQ[Sqrt[n]], -n, n], {n, 0, 70}]] (* Harvey P. Dale, Jan 17 2017 *)
PROG
(PARI) g(n) = my(s=0); for(x=0, n, if(issquare(x), s-=x, s+=x); print1(s, ", "))
(Magma) [0] cat [&+[i*(-1)^#Divisors(i):i in [1..n]]:n in [1..70]]; // Marius A. Burtea, Oct 09 2019
CROSSREFS
Cf. A000005, A000290 (squares).
Sequence in context: A164108 A064520 A267313 * A134530 A351571 A308678
KEYWORD
easy,sign
AUTHOR
Cino Hilliard, Jun 13 2005
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 10:42 EDT 2024. Contains 371967 sequences. (Running on oeis4.)