Lets say I have a simple for loop with an index i that goes from 0 to n. I want to be able to loop by i and each loop generate two numbers in the following sequence:
i | a | b
=========
0 | 2 | 1
1 | 2 | 3
2 | 2 | 5
3 | 5 | 1
4 | 5 | 3
5 | 5 | 5
6 | 9 | 1
7 | 9 | 3
8 | 9 | 5
9 | 12| 1
10| 12| 3
11| 12| 5
12| 16| 1
...
Basically, the algorithm is, for a it starts with 2 and increments by 3 and 4 in turns, whereas for b it always goes through 1, 3 and 5 and then starts over.
I have been trying to produce something without much result. I would prefer an answer in java but pseudocode or any non-esoteric language will do fine.
1 Answer