Looking for a formula to find each pair of previous sums in an incremental series that will equal the next sum in the sequence

30 Views Asked by At

I imagine this should be easy for a lot of you, or maybe is a well known thing.

So, I am looking to find previously found value pairs that can sum to the next value in a sequence that increments by one.

Example:

base value = 1 2: (1+1) 3: (1+2) 4: (1+3, 2+2) 5: (1+4, 2+3) 6: (3+3, 2+4, 5+1) 7: (3+4, 2+5, 6+1)

so... it looks like it is each pair i,j where i = 1 up to floor(k/2)+1 and j = k-i

did I get this correct? thanks for help

1

There are 1 best solutions below

0
On BEST ANSWER

If I understand your question correctly: You want to know how many ways you can find two natural numbers that sum to a given natural number, $n$.

Then, in your notation, the possibilities are:

$$(1, n-1), (2, n-2), (3, n-3), \ldots, (n-3, 3), (n-2, 2), (n-1, 1)$$

But, it looks like you don't want to count $(a, b)$ and $(b, a)$ as distinct.

So, you can have the first entry go from $1$ to the halfway point, which (as in your post) is either $n/2$ if $n$ is even or $(n-1)/2$ if $n$ is odd.

Indeed, this can be rewritten as $\text{floor}(n/2)$ in total, just as you observed.