English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

10 answers

Turn math.ran into a whole integer, and multiply it by 2.

Bingo.

2006-08-09 04:07:19 · answer #1 · answered by © 2007. Sammy Z. 6 · 0 0

Program for a range of random numbers if necessary -- say 1 to 100 inclusive. When you get a number (save it) perform a modulo (%). If it is a multiple of 2, the result (remainder) is 0. Success. If the result/remainder is 1. Failure and go again. As someone said, the results are not really random. You ought to be using paranormal statistics (mean becomes median) but the nice thing is you can define your procedure any way you want! Well, maybe grounded in lab reality. cjb

2006-08-09 04:16:26 · answer #2 · answered by CJB 1 · 0 0

Exactly what others said -

Say you want an even number from 1-100

Generate a random number from 1-50 and multiply it by 2.

2006-08-09 04:12:19 · answer #3 · answered by boris 5 · 0 0

I'd suggest wrapping the call in a loop which checks for appropriate results. In your case even numbers. You could also take it one step further and create a little function to do it for you. Here's one in VB :-

Function GetRandomEvenNumber(ByVal intMinValue As Integer, ByVal intMaxValue As Integer) As Integer
Dim RandomGenerator As System.Random = New System.Random
Dim tmpValue As Integer = 1

Do While ((tmpValue Mod 2) <> 0)
tmpValue = RandomGenerator.Next(intMinValue, intMaxValue)
Loop

Return tmpValue
End Function

He're now to use it

TextBox1.Text = GetRandomEvenNumber(1, 100)

2006-08-09 04:29:29 · answer #4 · answered by andre_boyle 1 · 0 0

Generate a random number and then multiply it by 2. It will always be even.

2006-08-09 04:08:15 · answer #5 · answered by Winner4600 3 · 0 0

Doesn't that defeat the purpose? It would no longer be a random number if you limited to only even numbers.

2006-08-09 04:07:37 · answer #6 · answered by Anonymous · 0 0

Wow. So you want to produce random numbers without randomness.

TFTP

2006-08-09 04:08:40 · answer #7 · answered by Anonymous · 0 0

just make it double

2006-08-09 04:13:25 · answer #8 · answered by Anonymous · 0 0

That is a damn good question.

2006-08-09 04:06:36 · answer #9 · answered by Matt S 2 · 0 0

wish i knew!!!!!!!!!lol

2006-08-09 04:10:17 · answer #10 · answered by Anonymous · 0 0

fedest.com, questions and answers