How do I return a fixed random number ?, Returns a fixed random number?
Fixed random numbers are often used in Java programming. Beginners often have a headache with this fixed random number. Is there any formula that can be easily achieved?
Of course, the formula is as follows:
Math. random () * (n-m) + m
For example, a random number between 25 and 45 is required, Math. random () * (45-25) + 25, that is, Math. random () * 20 + 25, note that the forced conversion type int num = (int) (Math. random () * (20) + 25
Use the same Random!
In java, how does Mathradom () return a random number between two fixed values, for example, 15-24? I remember it, but now I forget it.
Returns a random number of 15-24.
Math. random () * (24-15) + 15;
--------------------------------------
Returns m ~ Random Number of n
Math. random () * (n-m) + m
How does Excel generate a fixed random number?
= CHOOSE (INT (3 * RAND () + 1), 59.5, 60, 60.5)