Skip to main content
1 of 6
JungHwan Min
  • 13.9k
  • 3
  • 23
  • 69

#Mathematica, 49 bytes

f@2=4;f@1=0;f@n_:=Tr@Range@f[n-1]-Tr@Array[f,n-1]

Defines function f. 1-indexed.

JungHwan Min
  • 13.9k
  • 3
  • 23
  • 69