Math.random question

Simple question just for assurance. Using math.random(x,y), does it count the 2 numbers specified as part of it’s range?
Example:

 print(math.random(1,3))
-- possibly return 1,2, or 3
print(math.random(1,3))
-- only return 2
1 Like

Yes, it will have a chance to return the min and max number.

2 Likes

The randomness is actually a pseudo-randomness. To improve its randomness, math.randomseed(os.time()) may help. Additionally, math.random(3) is the same as math.random(1, 3), because the minimum value becomes automatically 1 if no specified 2nd argument was found.

1 Like