Disclaimer: I'm a 19 year old who didn't pay enough attention in math class, so there is likely a very simple solution to this that I just can't think of.

I'm writing an algorithm that will run forever. For unrelated reasons, I want to sum up to 1 billions during steps 1 through 2,628,000. The catch is, I would like to decrease the value that is getting summed as n, the number of iterations, increases. I will always be starting at 0 and want to sum up to exactly 1 billion after 2,628,000 iterations.

In other words, lets say I wanted to do this in 10 iterations with the number 100, starting at 0:

  1. 0 + 27
  2. 27 + 18
  3. 45 + 15
  4. 60 + 11
  5. 71 + 10
  6. 81 + 8
  7. 89 + 6
  8. 95 + 3
  9. 98 + 1.5
  10. 99.5 + 0.5

I've looked at quadratic bezier curves as they seem to do what I want but I've read that it's very difficult (or impossible) to calculate y based on x (x in my case would be the iteration number).

Any help with a formula would be very much appreciated.


closed as off-topic by Namaste, Xander Henderson, user10354138, max_zorn, Parcly Taxel Nov 3 '18 at 5:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Namaste, Xander Henderson, user10354138, max_zorn, Parcly Taxel
If this question can be reworded to fit the rules in the help center, please edit the question.


So, you want numbers $a_1>a_2>\cdots>a_m>0$ with $m=2628000$ and $a_1+a_2+\cdots+a_m=1000000000$. There are infinitely many ways to achieve this goal. Here's one of them:

Calculate $1+2+\cdots+2628000$. Call the answer $Q$. Then let $a_i=1000000000i/Q$ for $i=1,2,\dots,2628000$.


Not the answer you're looking for? Browse other questions tagged or ask your own question.