# Formula to Calculate Series Result

#### Pips

##### New member
I have two sets of numbers, A & B. A can be have repeating values 1... n. B will also have values 1..n, but each will repeat A times. So, we could have:-
A: 1,1,1,1,1,1,1,...
B: 1,2,3,4,5,6,7,...
or
A: 1,2,1,2,1,2,1,2,...
B: 1,1,2,2,3,3,4,4,...
or
A: 1,2,3,1,2,3,1,2,3,...
B: 1,1,1,2,2,2,3,3,3,...
etc.
The goal is to derive a third value C that will simply be integer values from 1, 1,2,3,4,..., in each case.
I am looking for a simple algorithm to get C whatever the values of A and B might be.
I have concocted an answer, but it looks overly-complex and inelegant to me, I think there is a better solution out there.

#### Jomo

##### Elite Member
1) A is defined as a set of numbers. Although I understand what you meant to say, saying B will also have values 1..n, but each will repeat A times really makes no sense at all.
2) You did not define C very well. Based on how you defined C(or failed to define C), C can be anything. What is the connection between C and A&B?

#### Pips

##### New member
If you look at my examples, you will see what I mean, the integers in B repeat however many unique integers there are in A.

C will contain the integers 1, 2, 3, 4, .. and I am trying to derive an algorithm that will get me C.

So in my first example, an algorithm (or formula if you will) that will get 1 for the answer C when A = 1 and B = 1; 2 when A = 1 and B = 2, etc. That example is simple, but in the second example, I want 1 for C when A = 1 and B =1, 2 when A = 2 and B = 1, 3 when A = 1 and B = 2, 4 when A = 2 and B =2; in the third example I want 1 for C when A = 1 and B =1, 2 when A = 2 and B = 1, 3 when A =3 and B =1, 4 when A =1 and B =2, 5 when A =2 and B =2, and so on.

Is that clearer?

#### Dr.Peterson

##### Elite Member
We still need a little more clarification; you are using terms incorrectly, and asking an unclear question.

This time you presented A, B, and C as if they were variables, with C being a function of A and B. But it is not; the value of C depends not only on the current values of A and B, but on their history (and particularly on n).

I see it more as three sequences. The first, $$\displaystyle A_k$$, just counts up to some number n repeatedly. The second, $$\displaystyle B_k$$, starts at 1 and repeats until $$\displaystyle A_k$$ resets to 1, then increments by 1. It's almost as if you were counting out objects into a number of piles, like dealing cards: while you count 1, 2, 3, you put down card 1 in each of 3 piles, then you count 1, 2, 3 again while dealing 2's, and so on. Is that the idea? The number n could be anything, but must be known.

Then I think that $$\displaystyle C_k$$ is just 1, 2, 3, 4, ... . If so, then there is nothing to derive, as I see it!

My guess is that you want to be able to determine the term in sequence C, given only the value of n and the corresponding terms in sequences A and B. So if I look at the card in front of me and hear the number you said when you put it there, you want me to be able to say how many cards are now on the table. Right?

It would have been great if you had shown us your algorithm, which would illustrate what you want.

But here's my answer, if I've interpreted the problem correctly: Given n, B tells which repetition of the count from 1 to n you are on, and A tells you where you are in that count. To find the total number of cards dealt, we find that there have been (B-1) complete repetitions of n, and A more individual "cards", so that C = n(B-1)+A.

For example, for n=3, A=2, and B=2, C = 3(2-1)+2 = 5, as you said it should be.