If you want to iterate through all 16,777,216 possible 24-bit RGB colors, this can be achieved quite simply with a single loop:
for( i=0; i < 1<<24; i++) {
r = (i>>16) & 0xff;
g = (i>>8) & 0xff;
b = i & 0xff;
colour = "rgb("+r+","+g+","+b+")";
}
In your code, with an interval of 100, it will take almost 20 days to go through one cycle.
If you're fine with fewer colors, try the following:
for( i=0; i < 1<<12; i++) {
r = ((i>>8) & 0xf) * 0x11;
g = ((i>>4) & 0xf) * 0x11;
b = (i & 0xf) * 0x11;
colour = "rgb("+r+","+g+","+b+")";
}
4 , # 000000, # 000011, # 000022 .. Rutime 100 41 4096 .