how to generate twin numbers using math.random ?

Hi, I want to generate random twin numbers, 2,4,6,8,10,12 …ets.

is this possible or not ?

Yes it’s possible, you just include a test of the random result to see if it’s one of the possible numbers you want. If yes keep it, if not create another one, retest it.

T.

Hi @Toe

I think I didn’t understand you, can you tell me more about it.

I’m not sure what you mean by twin numbers, but if you mean even numbers, this is pretty easy.

If you want a range of numbers from 2 to 10 do:

local number = math.random(1, 10) * 2

Rob

Hi Rob.

Yes this is what I was looking for. thanks alot.

Yes it’s possible, you just include a test of the random result to see if it’s one of the possible numbers you want. If yes keep it, if not create another one, retest it.

T.

Hi @Toe

I think I didn’t understand you, can you tell me more about it.

I’m not sure what you mean by twin numbers, but if you mean even numbers, this is pretty easy.

If you want a range of numbers from 2 to 10 do:

local number = math.random(1, 10) * 2

Rob

Hi Rob.

Yes this is what I was looking for. thanks alot.