How do I solve an arithmetic sequence?
How does:
(1 + 2 + ... + N) / N = (N + 1) / 2
or
(1 + 2 + ... + N + N) / N = (N + 3) / 2
My textbook says this is elementary math but I have开发者_如何学Go forgotten the method for finding the answer.
The example you gave is called an arithmetic sequence, not a geometric sequence.
A simple way to convince yourself that the result is correct is to write the same sequence backwards, add it to itself, and divide by 2:
1 + 2 + 3 + ... + N-1 + N = S
+ N + N-1 + N-2 + ... + 2 + 1 = S
--------------------------------------
N+1 + N+1 + N+1 + ... + N+1 + N+1 = 2S
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
N terms
= (N+1)*N = 2S
(N+1)*N/2 = 2S/2 = S =
**S = (N+1)*N/2**
Mathematical induction. http://en.wikipedia.org/wiki/Mathematical_induction#Example
The second claim you stated follows from the first by just adding N / N = 1 = 2 / 2
.
Sum of n natural numbers is denoted by n(n+1)/2.
So the given the first problem you have correctly mentioned the output will (n+1)/2.
for the second problem.
the solution is (n(n+1)/2n)+n/n = (n+1)/2 +1 = (n+3)/2. You would observer actual series is sum of n natural numbers plus n. So thats how i split the terms.
精彩评论