Having Trouble with this For Loop

This is quite hard to articulate, but this is what I’m Attempting to do:


So I may end up with an array of indexes as:
192504-index-list.png

Currently what I’ve been trying to do is take some givens:
i = current row; (1,2,3…7)
r = Square Root of Total Indexes -1
(total indexes will always be a square of 2, a la 64,128, 256…)

i=1, so i+r Once.
i=2, i+r Twice.
i=3, i+r Thrice.

and so on and so forth…

Well the difference between the next digit in the sequence is always 7, by induction. And you always continue adding 7 to get to the next digit until you’ve counted n numbers (where n is the row number).
Then you reset the counter and start from the digit n - 1. And you repeat. This is the pattern until row number = 8.


So here’s the full algorithm:

var numbers = new List<int>();

int rowNum = 1;
int counter = 0;

// First loop
while (rowNum <= 8)
{
    int num = rowNum - 1;
    numbers.Add(num);

    while (counter < rowNum - 1)
    {
        num += 7;
        numbers.Add(num);

        counter++;
    }

    counter = 0;
    rowNum++;
}

int offset = 1;

// Second loop
while (rowNum < 16)
{
    int num = rowNum - 1 + 7 * offset;
    numbers.Add(num);

    while (counter < rowNum - offset - 2)
    {
        num += 7;
        numbers.Add(num);

        counter++;
    }

    counter = offset;
    rowNum++;
    offset++;
}

@FaffyWaffles