Skip to main content
latex formula
Source Link
A.G.
  • 4.4k
  • 14
  • 18

A mathematical approach: $\sum_{k=1}^n (-1)^{k+1} s_k$ translates as follows

s = {a, b, c, d, e, f, g, h};
Sum[(-1)^(k+1) s[[k]], {k, 1, Length[s]}]
(* a - b + c - d + e - f + g - h *)

A mathematical approach:

s = {a, b, c, d, e, f, g, h};
Sum[(-1)^(k+1) s[[k]], {k, 1, Length[s]}]
(* a - b + c - d + e - f + g - h *)

A mathematical approach: $\sum_{k=1}^n (-1)^{k+1} s_k$ translates as follows

s = {a, b, c, d, e, f, g, h};
Sum[(-1)^(k+1) s[[k]], {k, 1, Length[s]}]
(* a - b + c - d + e - f + g - h *)
Source Link
A.G.
  • 4.4k
  • 14
  • 18

A mathematical approach:

s = {a, b, c, d, e, f, g, h};
Sum[(-1)^(k+1) s[[k]], {k, 1, Length[s]}]
(* a - b + c - d + e - f + g - h *)