Start with string 00000.
Loop
{
Output current string.
Look at far right value.
If it's 0, change to to 1. Back to loop start.
If it's 1, change it to 2. Back to loop start.
If it's 2, change it to zero and look at next value along:
If it's 0, change to to 1. Back to loop start.
If it's 1, change it to 2. Back to loop start.
If it's 2, change it to zero and look at next value along:
If it's 0, change to to 1. Back to loop start.
If it's 1, change it to 2. Back to loop start.
If it's 2, change it to zero and look at next value along:
If it's 0, change to to 1. Back to loop start.
If it's 1, change it to 2. Back to loop start.
If it's 2, change it to zero and look at next value along:
If it's 0, change to to 1. Back to loop start.
If it's 1, change it to 2. Back to loop start.
If it's 2, stop
} |
This is counting. It's how you would count numbers up from zero. When you count up from 0, every time you get to 9, you increase the next digit by 1, and then go back to increasing the far right digit again. Like this:
...
07
08
09
What's next?
(0+1) (0 ) , which is 10
11
12
13
...
0999
What's next? Well, change the far-right 9 to a zero, and then increment the next number along. Oh, it's 9; change it to zero, increment the next number along. Oh, it's 9; change it to zero, increment the next number along...
1000
This is just counting up. That's all it is. But instead of going back to 0 after 9, you go back to 0 after 2.
000
001
002
What's next? The 2 becomes a zero, and we add one to the next digit.
010
011
012
What's next? The 2 becomes a zero, and we add one to the next digit.
020
021
022
What's next? The 2 becomes a zero, and we add one to the next digit. Oh, it already is two. So we make it zero and then add one to the next digit:
100
101
102
What's next? The 2 becomes a zero, and we add one to the next digit
110
111
112
...