Rebirths math problem

What I would do is make an algorithm for the price to go up. I don’t see a reason for you to use a for loop, just make an algorithm that handles it.

Demonstration:

local PRICE_INCREASE_PER_REBIRTH = player.leaderstats.Rebirths.Value + 1000 / ( player.leaderstats.Rebirths.Value * 5)

This add’s the player’s rebirth value by a thousand and then divides it by the amount of rebirths the player multiplied by 6. ( It doesn’t increase the rebirths, just an algorithm )

Yes, that’s simple but what if player wants to do over a million rebirths? The script would crash.

A million rebirths at once?!?!

Yea, like tapping simulator? That’s why I dont want to use a for loop.

Well I highly doubt that anyone would do that many rebirths at once, however under that case, you could use that script to log the price of each rebirth
Create a table,
Put something like this into the loop

table.insert(rebirthCostTable, rebirthCost)

Then you could call it, otherwise I would look into the algorithms that others have posted here :stuck_out_tongue:

Why are you guys making it this complicated, just use a exponential scale. Any equation of the form y=n^x will work fine, where n is the steepness of the function and x would be the amount of rebirths which you can track by your own means. Using a for loop for any sort of math that isn’t integration(but even integration in most cases) is a massive sign you’re doing something terribly wrong.

he wants the total price of multiple iterations of buying a rebirth not just the price of a specific rebirth

Yes, exactly, I want to be able to calculate the next price and add it to the current one.

Then just integrate whatever formula (exponential formula in this case) for calculating the price and do the exact same thing.

My question is what is the formula?

This is exactly what arithmetic series sums do as I have said above. To get the price of x amount of rebirths it would be s(currentRebirths + x) - s(currentRebirths) where s is the sum function. Refer to my post above for code.

I edited post above, but here it is again:

scale = 10000
final_cost = 0.5*scale * HowManyRebirths * (HowManyRebirths + 2*RebirthsIHave - 1)

Wow, thank you! This is what I was looking for! I printed it and it printed out the exact number I wanted.

1 Like

that will give you your first rebirth free
just so you know

1 Like

Yea, I’ll try to find something for this by myself. Thanks for this notice!

check my first response, it is a very similar formula but it shifts everything 1 spot so starting at 0, it is 10k

local e = 10 -- steepness of the scale

function expoScale(x)
  return e^x
end

function expoScaleInt(x)
  return (e^(x+1)-1)/(e-1)
end

is what you want

But I don’t understand it, could you repost it more clearly now?

Yours work perfectly but doesn’t include how many rebirths you have rn.

expoScale gives you a curve exponentially increasing by e, expoScaleInt is the analytic form for the series sum of that function.