#Mathematica, 49 48 bytes
Mathematica, 49 48 bytes
±2=4;±1=0;±n_:=Tr@Range@±(n-1)-Tr@Array[±#&,n-1]
(* or *)
±2=4;±1=0;±n_:=-Tr@Array[(k=±#)&,n-1]+Tr@Range@k
Uses CP-1252 encoding. Defines function PlusMinus (±)
. 1-indexed.
#Explanation
Explanation
±2=4;±1=0;±n_:=Tr@Range@±(n-1)-Tr@Array[±#&,n-1]
±2=4;±1=0; (* Define ±1 and ±2 *)
±n_:= (* ±n equals ... *)
Tr@Range@±(n-1) (* Sum of (1, 2, ..., ±(n-1)) ... *)
-Tr@Array[±#&,n-1] (* Minus the sum of previous terms *)