I think that will give you random numbers from 2 to 6. You should change the 5 to a 4. The % 4 will give you numbers from 0-3 then the +2 will change that to 2-5. If I'm reading it correctly.
FWIW...if you look at ScreenSaverView.h (spotlight it), Apple has some inline functions for generating random numbers (for copying into your source code). Kind of handy if you just need something quick.