Why does the j index start from 2 not 1 in this double For loop
For[i = 1, i <= 2, i += 1, For[j = 1, j <= 2, j += 1; Print[{i, j}]]]
{1,2}
{1,3}
{2,2}
{2,3}
Why does the j index start from 2 not 1 in this double For loop
For[i = 1, i <= 2, i += 1, For[j = 1, j <= 2, j += 1; Print[{i, j}]]]
{1,2}
{1,3}
{2,2}
{2,3}
The syntax for a For loop is:
For[start,test,incr,body]
But you wrote for "j":
For[start,test,incr; body]
note the ";". If you replace ; by , it works:
For[i = 1, i <= 2, i += 1, For[j = 1, j <= 2, j += 1, Print[{i, j}]]]