Hi Teresa,
You can get coding help at this level by Googling how to do things in Perl. (As opposed to issues with MathObjects, Contexts, and other things that are specific to WeBWorK's PG modules.)
It sounds like you might want to use a loop through the full array 0 through 21, and that you might be interested in the modulus operator, which is the percent character. If I understand right, you could do:
for $i (0..21) {
if ($i % 3 == 0) {do this;}
else {do that;}
}
Does that help?
If you only want to take action on multiples of 3, you could generate the array (0,3,...,21) and do like this:
for $i map{3*$_} (0..7) {
do this;
}
The part that goes "map{3*$_} (0..7)" is taking the array 0 through 7, multiplying everything by 3, and leaving you with (0, 3, 6, 9, 12, 15, 18, 21). Then $i only iterates through those values.