I want to generate every possible combination of numbers, with n beeing the highest.
Eg:
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2
My current approach to this is pretty simple, just n for loops.
The problem with this is, that I don't know n.
n = 3;
for (a=0; a <= n; a++) {
for (b=0; b <= n; b++) {
for (c=0; c <= n; c++) {
console.log(`${a} ${b} ${c}`);
}
}
}
I need a way of generating these loop dynamically.
Any other approach for generating all possibilities is also welcome.
nas a parameter? I don't understand your question.