To make this easier to conceptualize, both for myself and for the reader, let us say that you have 5 machines with varying costs and varying rates expressed as dollars per hour.

Mock Example

Let us say that we start with no money, but we get given machine 1 for free, which generates $3/h. There are 4 more machines, each machine after the other costing more, but having a greater dollar/hour rate, generating money more quickly.

Based off only this information – the price of the machine, and their dollar/hour rate – how could one calculate the fastest of accumulating the sum total of $5000?

Note that am not at all interested in the aforementioned example, only the overarching principles which could be applied to any given scenario such as this.

  • Can each machine be bought only once? Mar 4, 2019 at 18:14

3 Answers 3


As the money is accumulated the lowest price machine is bought until you have them all. This is the optimal order in which to purchase the machines. $5010 is accumulated in 326 hours.

table = {{500, 5}, {800, 15}, {1200, 27}, {Infinity, 42}};
money = hrs = rate = 0;
cost = 200;

While[money < 5000,
 If[money >= cost,
  money -= cost;

  (* reset the cost threshold and rate *)
  {cost, rate} = First[table];

  (* discard the first table entry *)
  table = Rest[table]
 money += rate;
 money += 3]

enter image description here


Each machine has to earn enough to buy the next machine but also has previous machines helping. Then the last machine has to make the $5000 but also has previous machines helping:

3x - 0 = 200 with x = 66.67 hours

5x + 3x = 500 with x = 62.5 hours

10x + 3x + 5x = 800 with x = 44.44 hours

12x + 3x + 5x + 10x = 1200 with x = 40.00 hours

15x + 3x + 5x + 10x + 12x = 5000 with x = 111.11 hours

The total hours for the five machines to make $5000 is 324.72 hours.

Compare to the first machine making the $5000 by itself at 1666.67 hours.

Compare to the first and second machines making the $5000 at 691.67 hours.

Compare to the first, second, and third machines making the $5000 at 406.95 hours.

And compare to the first, second, third, and fourth machines making the $5000 at 340.28 hours.


You need to know the breakeven point of the machine. If a machine generates $10/h and costs $500 then you need 50 hours before breakeven.
Now if the end goal takes longer than 50 hours you buy the machine because it'll make it faster, if not, you don't.

You must log in to answer this question.

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