random() help

Is it possible to call a preset group of number randomly? Like say I wanted to only call 0,2,4,6 and 8. No other numbers, just those 5, but i wanted it to call them at random. The tutorial only show selecting two number like say 2,8, and it calls anything between them, but I only want it to randomly select predetermind numbers.

static const byte MyNumbers[5] = { 0, 2, 4, 6, 8 };

void loop( void )
{
byte RandomNumber;

RandomNumber = MyNumbers[ random( 5 ) ];
}

Call for a random 0 through 4, then shift the returned value left once to get even numbers 0, 2, 4, 6 or 8

So it has to be done through an array? Not that it is a lot of code to write, I was just hoping there was an easier way

Using an array is the most flexible option as next time you may need e.g. the numbers { 1, 2, 3, 5, 8, 13, 21 } that are more difficult to calculate directly.

So it has to be done through an array? Not that it is a lot of code to write, I was just hoping there was an easier way

This method is a single line of code. How much easier do you want it to be?