Calculating Hero Cost to buy up to a certain level

clicker-heroes

Frostleaf in my game is upgraded to level 2000, and I want to calculate the cost to buy another 1000 levels.

When trying to calculate my hero costs I ran into some problems.
The formulas I found seem simple enough and claim to be based on the source of the game. Specifically it says to use this for any Hero who is not Cid:

Hero_cost = Base_cost * 1.07^level

That seems straightforward. Looking up Frostleaf's base cost I found the value claimed was 2.1S aka 2.1e24. This seems to be the case in a new game. (update Note that it was 2.1, but the units was not S but O… this crept into the wikia edits when someone edited 2,1000S to 2.1S instead of 2.1O then someone else replicated this across the whole page.)

Yet if I put the following into a spreadsheet or calculator:

2.1e24 * 1.07^2000 I get
1.22963060815929e83

When I roll over Frostleaf in my game it tells me the following costs:

1: 5.902e85 (This is like about two and a half orders of magnitude higher than the formula result!)
10: 8.154e86
25: 3.733e87
100: 7.307e89

So, I must not be accounting for something and it doesn't seem to be a relic as they would reduce, not add, cost (looking only at buying 1 more Frostleaf). I've also used the formula backwards and it would seem that based on what is in my game, if the formula is true, the base cost of Frostleaf was ~1.008e27 again two and a half orders of magnitude higher.

Additionally assuming I figure out what this problem is with the simple formula, I still need to sum the cost of each level of hero bought, like:

sum(2.1e24 * 1.07^n) where:
n goes from 2000 to 2009 (should be 8.154e86)
n goes from 2000 to 2024 (should be 3.733e87)
n goes from 2000 to 2099 (should be 7.307e89)
and ultimately n goes from 2000 to 2999 (this is the number I would like to calculate)

If even the base formula and values I found don't accurately model buying the 2001st Frostleaf, then I can't move on to these next steps.

Help with either part would be much appreciated.

Best Answer

Wikipedia has a good article on geometric series, wherein the generalized formula for the sum is:

Sum_k=a_b(r^k)=(r^a-r^(b+1))/(1-r)

Where for Clicker Heroes purposes, given that:

  • 1.07 is the rate (r above), and
  • b is base cost,
  • l is current level
  • t is target level
  • s is total cost

It would be:

s = b(1.07l - 1.07t) / -0.07

But I still need to figure out why my base cost anchor point appears to be higher than I expected. Which is odd, because I had a -2% hero cost relic. Also without this relic I charted levels 1-2001 costs for Frostleaf and came out to a rate of 1.07 for each step. However my base cost was 1.05e27 which is ~10^3.5x the claimed base cost of 2.1e23. So maybe just the base cost was off... why though.

Update The wikia page was edited by someone who mixed up the meaning of . and , probably due to their own localization. I've just removed it, such that the base cost is now 2.1e27, correctly reflecting that I have 1/2 off cost through an ancient.