I'm doing a simple budget app, to make some calculations to improve private economy.

I've made an option where you can enter the value of the money that are in the bank right now, and how many days there are left in the month. Now it calculates the daily average. Fx if I enter 6400 at my account, and 18 days left, i will get that i can spend 355,55 pr day for the rest of the month. Simple division. So far so good.

But now i want to make an algorithm that can calculate, how much I can spend in x days, to improve the daily average for the rest of the month.

So I can enter some values:

M: How much there are on my account today (fx. 6400)

D: How many days there are left in the month (fx. 18) (here I will get the average of 355,55)

V: How much I will spend pr. day in x days, to improve the average (fx. 300).

A: How much I want to improve my average to, for the rest of the month (fx. 400).

If I have an average at 355,55 pr day for the rest of the 18 days in the month, how can I calculate how many days I would have to spend only 300 pr day, to get my average up to 400 pr day, for the remaining days of the month?

What kind of formula would I be using?

Thanks so much.

  • $\begingroup$ x is less than 18 for example, right? $\endgroup$ May 3, 2015 at 14:00
  • 1
    $\begingroup$ yes, x should be less that 18 in this example. If i only used 300 in all of the 18 days, I would have money left for next month, and I would never get to spent 400 in any of the days, so yes ;) $\endgroup$
    – Ziltoid
    May 3, 2015 at 14:02

1 Answer 1


M = Your currently money in the bank

D = Remaining days

L = The limited value for x days

I = Improved average or remaining days of the month

Now we must have :

$M-L*x >= (D-x)*I$

So you need to solve this equation :

$M>= L*x + (D-x)*I$



Maximum integer for $x$ plus 1 is the answer of your question.

Moreover, $400$ is too much for a day, try to save it for a rainy day with your GF :D

  • $\begingroup$ That is so sweet! THANKS! :D $\endgroup$
    – Ziltoid
    May 3, 2015 at 15:05

You must log in to answer this question.

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