Hmm... I don't know that I can break it down the way you want - certainly not this early in the morning.

However, I can explain what the listing does; hopefully that will help.
i=0
for red=0 to 7
for blue=0 to 7
for green=0 to 7
rainbow( i )=((red*3) mod
* 256
+green* 16
+blue
i=i+1
next
next
next
What this does, basically, is execute the line that starts with the word rainbow 512 times (8 * 8 *

. This is just making a list of the colors in each arc of the rainbow, one at a time. Each time it runs this line, red, green and blue have different values. The loops will get us through every single combination of these colors between 0d,0d,0d and 7d,7d,7d. The progression will go like this:
R G B
0 0 0
0 0 1
0 0 2
...
0 1 0
0 1 1
etc...
Now, this line has a color value on the right hand side of the equal sign, built by using arithmetic to put the bits for red, green, and blue into separate parts of the number so that it's a single quantity - just like an HTML color value except only half the bits.

In a 12 bit quantity like this one, the four most significant bits would represent red, the four in the middle green, and the low-order bits to blue, like so: rrrrggggbbbb.
The first part of the equation ((red * 3) MOD

- that is, the remainder of (red * 3) / 8 - is the red value. We multiply by 256 to shift the bits over to the left. Since 256 = 2 ^ 8, the bits are moved over by 10 places. So if red is 5, the number becomes 1792 (011100000000 - leading zero tacked on for clarity). Now we generate the middle five bits, for green, in the same way. If the green value is, for instance, 7, then 7 (00111) times 16 (10000) = 112 (01110000). Add these two quantities and you get 1904 (011101110000), and then you just add the blue value to it because as you see, those bits are blank, and the value of blue is constrained to be less than 8 so we don't have to worry about it changing the green value!
So now you have the color value to use for each of the 512 arcs that make up the rainbow, listed in order. Now, you want to have a separate number for each color value, presumably so you can punch them into some paint program. What you can do is change this:
rainbow( i )=((red*3) mod

* 256
+green* 16
+blue
to this:
reds( i )=((red*3) mod

greens( i )=green
blues( i )=blue
and then you'd just need to add a line at the end of this to output it. since i don't recognize the grammar this is constructed in, I can't give you a specific line to insert, but maybe someone else can help with that. [Translation of printf("r:%d g:%d b:%d", reds( i ), greens( i ), blues( i )) anyone?]
I hope this explanation will help you at the least understand the code well enough to come up with your table.