# Thread: Hello I Like Math

1. ## Hello I Like Math

I think math is fun. Problem is that I do not always know how to do what I am trying to. I must now rely on my fellow man to take his time, for free, and choose to give it away rather than sell it. I appreciate communities and their ability to come together to work a problem.

I have a problem. I will try to describe it the best way I can. I am not just looking for someone to do the work, I also want to know what this type of math is called and how it works.

So here is the problem:

I am trying to figure out the best order in which to subtract a list of numbers from a specific constant number to offer the best efficient solution. So as to minimize waste.

Thanks
Ryan

2. ## Re: Hello I Like Math

assuming the list is just random numbers the quickest method would be as follows.

$a_{0,i},~i=1,N$ (the reason for the zero will become apparent)

now form a new list

$a_{1,1}=$a_{0,1}+a_{0,2}a_{1,2}=$a_{0,3}+a_{0,4}$
.
.
$a_{1,k}=a_{0,2k-1}+a_{0,2k}$

i.e. we add adjacent pairs of numbers from the 0th list to come up with the 1st list.
Repeat to form $a_{2,k}, a_{3,k}$, etc. until there is only a single number left.

This number is the sum of all the numbers on your list.

To make this a bit clearer consider

$a_0=\{ 1, 3, -2, 7, 13, -5, -1, 6\}$

we form

$a_1=\{ (1+3), (-2+7), (13-5),(-1+6) \} =\{ 4, 5, 8, 5 \}$

$a_2 = \{ (4+5), (8+5) \}=\{ 9, 13 \}$

$a_3 = \{ (9+13) \} = \{ 22 \}$

so subtract 22 from your constant.