2
$\begingroup$

I would like to learn how to calculate the following in the most efficient way possible. I guess there is a math function existing that could do that. Right now i am using google sheet functions, but any programming language math functions will do.

Problem: We have $\$37950$. We have a daily income of $\$532$. For how many days in a row can we spend $\$2700$ in others words, how many days before the bankroll is under $\$2700$?

Current state: Now, of course starting money is good for $14$ days. Then in $14$ days we earn around $\$7473$ (it's ok to pretend we earn fractions). Thus prolonging the streak by close to $3$ days, etc, etc. Is there an elegant formula to calculate this?

Thanks.

$\endgroup$
2
  • 1
    $\begingroup$ Your net spending is $2700-532$ a day. Find it and divide the initial sum by that amount. $\endgroup$
    – Vasili
    Mar 31, 2022 at 21:09
  • 2
    $\begingroup$ You start with the fixed value of $\$37950.$ Each day, your net loss is $\$(2700 - 532) = \$2168$. So, you want $$\left\lfloor \frac{37950}{2168}\right\rfloor = 17.$$ $\endgroup$ Mar 31, 2022 at 21:09

1 Answer 1

1
$\begingroup$

As the comments have pointed out, the key is to use the net spending. Here's a bit of a longer answer that uses that method to get you a formula.

Let $Y_i$ represent the amount of money you have on day $i$, starting from day $i=0$, when you have $Y_0 = \$37{,}950$.

Then, on your first day, you earn $\$532$ and you spend $\$2{,}700$. That means the amount of money you have after day 1 is

$$ Y_1 = 37950+532-2700$$

On your second day, you start with $Y_1$ dollars, and you again earn $\$532$ and you spend $\$2{,}700$. That means the amount of money you have after day 2 is

$$ Y_2 = Y_1+532-2700 $$

Now, substitute in the expression we found for $Y_1$ above, and you've got

$$ Y_2 = \underbrace{(37950+532-2700)}_{Y_1}+532-2700 $$

Rearrange a bit, and you've got

$$ Y_2 = 37950 + 2\cdot (532-2700) $$

Similarly, if we calculate the amount we have on day 3, you start with $Y_2$, earn 532, and spend 2700, and you've got

$$ Y_3 = Y_2 + 532-2700 $$ $$ \Rightarrow Y_3 = \underbrace{37950+2\cdot (532-2700)}_{Y_2}+532-2700 $$ $$ \Rightarrow Y_3 = 37950 + 3\cdot (532-2700) $$

You can show using induction that this pattern holds, and on day $t$, the amount of money you have is

$$ Y_t = 37950 + t\cdot (532-2700) $$

Now, to know when you'll run out of money, you can just plug in $Y_t = 0$:

$$ 0 = 37950 + t\cdot (532-2700) $$ $$ \Rightarrow t = \frac{-37950}{532-2700} \approx 17.5 $$

So, you'll still have a positive amount on day $17$, but then go negative on day $18$.

You can also use this formula to see how long it takes to reach different balance amounts by plugging those balances in for $Y_t$, e.g., when will I reach a balance of $\$1{,}000$:

$$ 1000 = 37950 + t\cdot (532-2700) $$

Or, if you can go into negative balances (i.e., borrow money), you can also see how much you'll "owe" after a certain number of days, e.g., how much will I have overspent after $30$ days of this:

$$ Y_{30} = 37950 + 30\cdot (532-2700) $$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .