Fixed bug in calculating index

Java doc of Math.random() states it generates a number equal to or
greater than 0 but LESS than 1.0.