Skip to main content
Code Review

Return to Answer

added 121 characters in body
Source Link

Seems trivial. Pair them, each pair is worth -1.

f(1000) = 1 - 2 + 3 - 4 + ... + 999 - 1000
 = (1 - 2) + (3 - 4) + ... + (999 - 1000)
 = -1 -1 + ... + -1
 = -500

Odd n left as exercise for the reader.

(I wrote this when the question title still said "1 − 2 + 3 − 4 + · · ·", can't be bothered to switch all signs now.)

Seems trivial. Pair them, each pair is worth -1.

f(1000) = 1 - 2 + 3 - 4 + ... + 999 - 1000
 = (1 - 2) + (3 - 4) + ... + (999 - 1000)
 = -1 -1 + ... + -1
 = -500

Odd n left as exercise for the reader.

Seems trivial. Pair them, each pair is worth -1.

f(1000) = 1 - 2 + 3 - 4 + ... + 999 - 1000
 = (1 - 2) + (3 - 4) + ... + (999 - 1000)
 = -1 -1 + ... + -1
 = -500

Odd n left as exercise for the reader.

(I wrote this when the question title still said "1 − 2 + 3 − 4 + · · ·", can't be bothered to switch all signs now.)

Source Link

Seems trivial. Pair them, each pair is worth -1.

f(1000) = 1 - 2 + 3 - 4 + ... + 999 - 1000
 = (1 - 2) + (3 - 4) + ... + (999 - 1000)
 = -1 -1 + ... + -1
 = -500

Odd n left as exercise for the reader.

default

AltStyle によって変換されたページ (->オリジナル) /