Original Post
Okay this has nothing to do with gaming, but I figure I''m bound to have some bit of luck with this here since this is the smartest gathering of people I can think of...
Anyway, the task is to find a formula that can compute the sum of all the elements in a list that increases at a rate of number + element_number * static_step_size...
Example:
(The step here is 2)
0, 2, 6, 12, 20, 30, 42, ...
(0 + 2) = 2, 2 + (2 * 2) = 6, 6 + (2 * 3) = 12, ...
So if I asked for the sum to number 12, it''d be (0 + 2 + 6 + 12) = 20, the number 30 would be (0 + 2 + 6 + 12 + 20 + 30) = 70
As for the formula, it must be a mathematical formula and not an algorithm, and it should (but if you can find anyway to do it, that''s a start) be in terms of the variables: step and number.
Here''s some info you may find useful (or not):
For a static step (i.e. number + static_step_size), the formula is (number^2)/(2 * static_step_size) + (number / 2).
Example: Step size (3)
0, 3, 6, 9, 12
For 9, (9^2)/(2*3) + (9/2) = 13.5 + 4.5 = 18
Proof : (0 + 3 + 6 + 9) = 18 18 = 18
I''ve tried every method I can think of for the the 1st problem (it took me long enough to find the 2nd), and I''m hoping someone else will have better luck than I have, because I''ve thrown probably 10+ hours down the drain trying to find the solution.
The purpose of all this crap is I have an idea on how to solve cubic equations using pattern anylsis, and I''ve got it all down except for this last pattern... So any help is appreciated,
Thanks,
-Jesse