# Thread: Which Numbers in a Geometric Sequence Equal a Given Total

1. ## Which Numbers in a Geometric Sequence Equal a Given Total

I have a sequence of positive integers. They were created using geometric progression: initial_value x (ratio^(nth-1))
For example; if initial_value=1 , ratio=2 , and nth begins at 1 and increases +1 every iteration; I end up with a sequence of 1,2,4,8,16,32,64,...

If, just for example, three integers from the above sequence were taken at random and added together, lets say they equaled 25(1+8+16).
Given the sum, is there an equation that can give me the integers that were taken?
For my particular situation, I will always have access to the initial_value, the ratio, and the nths used to create the sequence, the final maximum value of the sequence, and the sum of the integers taken.

2. ## Re: Which Numbers in a Geometric Sequence Equal a Given Total

If the value of ratio is always an integer (is it?) then you can do this:

The largest value that was used is A=Initial x R^[floor(log_{Base R}(N/initial))]. Here floor(x) means rounding x down to the nearest integer. Then subtract Initial x R^A and repeat. Keep going until the remainder is 0.

Here's an example: suppose initial = 3, R= 2, and the sum is 33. The first value is 3 x 2^[floor(log_2 (33/3))] = 3 x 2^[floor(log_2 (11))] = 3 x 2^3 = 24. Now subtract 24 from 33, leaving 9. The next value is 3 x 2^[floor(log_2(9/3))] = 3 x 2^1 = 6. Subtract 6 from 9 leaving 3. The last value is 3 x 2^[floor(log_2(3/3)] = 3x2^0 = 3. Hence the three values used are 24, 6, and 3.

Hope this helps.

3. ## Re: Which Numbers in a Geometric Sequence Equal a Given Total

The value of ratio is always an integer, yes.

Your method seems to work fine for me. Thank you very much for your time and help. I truly appreciate it.