#random number between 0-20 or 30-40

1 messages · Page 1 of 1 (latest)

cunning sequoia
#

Soooo basically how would I do it that it picks a random number between 0-20 or 30-40
My idea would be
(Idk how to make the symbols on Handy so you have to live with that):
Local numbers = {
Math.random(0,20),
Math.random(30,40)
}
Local number = numbers[math.random(1,#Numbers]

But the problem with that would be that the chance for a number 30-40 ½ * 1/10 is so 1/20
But for a number 0-20 ½ * 1/20 so 1/40 is which means the numbers 30-40 are more often sooo how would I do it that every number has the same chance?

surreal solstice
#

If math.random() > 0.666 then do 1-20. Else do 30-40.

native maple
cunning sequoia
coarse vapor
quasi stratus
#
local number
repeat
  number = math.random(0,40)
until not (number > 20 and number < 30)

print(number)