views:

47

answers:

1

so say i have a grid:

0 - 1 - 2 - 3

4 - 5 - 6 - 7

8 - 9 - 10 - 11

12 - 13 - 14 - 15

(but will be more rows...)

how can i find out programmatically if a random number (within the range of the numbers) is equal to the far right number: 3,7,11,15...?

thanks

+3  A: 
if ( ( random_number + 1 ) % number_of_columns == 0 ) {
  // on right
}
drawnonward
Thanks drawnonward! I really must learn how to use modulus
daidai