How to calculate price for stamps?

88 Views Asked by At

I'm trying to create a programm that has the ability to calculate the most effective way of breaking down the number of stamps (3 and 5 cent) necessary for a consignment. That is - if a transmission costs, for example, 11 cents, it would take one 5 cent stamp and two 3 cent stamps. The minimum price for a transmission is 8 cents.

Can you please help me come across on how to calculate that?

Thank you.

EDIT: Strong inducti0n with 3- and 5-peso notes and can pay any number greater than 7.

2

There are 2 best solutions below

0
On

Maybe a linear program helps:

$Min \ \ c-3x-5y$

$3x+5y \geq c$

$x,y \in \mathbb N_0$

With this program you can minimize the loss.

greetings,

calculus

0
On

Since you are using a program and we know that some such combination exists, start with the number of 5's that are equal or greater than the required quantity. If equal then you are done, otherwise reduce the fives by 1 and if the difference is a multiple of three you are done.

Repeat this process until you get a match.

Result maximises the number of fives and therefore minimises total number of stamps.