       Re: Calculating a given total using only given specific

• To: mathgroup at smc.vnet.net
• Subject: [mg104298] Re: [mg104294] Calculating a given total using only given specific
• From: Zach Bjornson <bjornson at mit.edu>
• Date: Tue, 27 Oct 2009 04:56:27 -0500 (EST)
• References: <200910260426.XAA18616@smc.vnet.net>

```There's probably a nicer way to do this using higher functions in
Mathematica, but using only basic functions:

OK = {56, 38, 20, 12, 4, 1};

While[total < target,
i = 1;
While[OK[[i]] > target - total, i++];
total += OK[[i]];
Print[OK[[i]]]
]
]

-Zach

On 10/26/2009 12:26 AM, Rick T wrote:
> Calculating a given total using only given specific values
>
> Greetings All
>
> I'm trying to figure out a way to calculate a given total
> using only given specific values.
>
> Example:
> The total given is 46
> The numbers I can use are 56,38,20,12,4, and 1
> so the numbers it should use and come back with would be highest to
> lowest
> so it should be 38,4,and 4 because
> these will add up to 46.  Is there a name given to this type of
> mathematics?
>
> And does anyone have an example of how to do this?
>
> tia sal22
>
>

```

• Prev by Date: Re: Using "/@" Effectively
• Next by Date: Re: Using "/@" Effectively
• Previous by thread: Calculating a given total using only given specific values tia sal22
• Next by thread: Re: Calculating a given total using only given specific