I am trying to come up with an algorithm to generate a nested array of consecutive numbers using only one loop. I feel it should be solved somehow using remainder operator but can't quite come up with a general solution. Anyone has any suggestion or hints?
input: 4 output: 1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4