S
S
Sergey Pankov2020-02-19 19:18:10
Mathematics
Sergey Pankov, 2020-02-19 19:18:10

How to calculate the sum of the series С[n]=1/(a+0)+1/(a+1)+1/(a+2)+...+1/(a+n) in O(1)?

It is necessary, in fact, to calculate the sum of the series С[n]=1/(a+0)+1/(a+1)+1/(a+2)+...+1/(a+n) in O (1).
The question is related to this question: How can I replace the way to choose a random value with less memory consumption, or is there an alternative to random.choises()?
As an alternative, you can try to solve another, more useful problem:
In O(1) determine min(i) for which C[i] > X.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lamerok, 2020-02-25
@lamerok

Approximately, you can do this: ln(a+n) + 1/((a+n)*2) - ln(a-1) - 1/((a-1)*2), more precisely, the error can be reduced, counting it through the Bernoulli numbers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question