Answer the question
In order to leave comments, you need to log in
How to calculate the nth sum of a series?
Problem for algorithms.
Condition: Count
Input: x, d, q, n.
Restrictions:
By simple summation, it gives the Timelimit. Tell me how to be
Answer the question
In order to leave comments, you need to log in
can be calculated analytically. I won’t deduce the formula in its entirety (it will even be written down here), but the idea is this: the
initial common term of the series a i = x*q i + i*d*q i
the first part is an ordinary geometric progression, the second is more interesting, up to a constant : i*q i
To find the sum of such a series, you can write it like this:
q
+
q 2 + q 2
+
q 3 + q 3 + q 3
+
...
+
q n + ... + q n
and sum not by rows, but by columns. Each column is a geometric progression with the sum (q n+1 - q k )/(q - 1)
This case must be summed over k - here is a constant + a common term of a geometric progression, everything is simple. Answer: (n*q n+1 - (q n+1 - q)/(q-1)) / (q-1)
Then put everything together with constants into one formula.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question