I often find the need to loop through numbers in a series. For example, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, … or 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, …
I don’t think I need help with the code (see below), but what is the correct name for this so I can look up other examples. And, is there a repository of these? If not, should there be?
int j;
void setup()
{
size(40, 40);
for (int i = 0; i < 80; i++) {
j = (i/4) + 1;
println("i:",i,"j:",j);
}
}
int j;
void setup()
{
size(40, 40);
for (int i = 0; i < 80; i++) {
j = (i % 4) + 1;
println("i:",i,"j:",j);
}
}