Question:
How do I generate a random number?
lee_lee07770
2010-04-19 07:11:02 UTC
Can you please help me with formula's that would generate a random number? I can NOT use any random number generators...but I can use outside factors from the equation such as using the current seconds of the day, etc. Just nothing that already generates the random number for you!

Please help! I've searched online high and low, and all the things online that I could find use a random number generator method or tool!
Three answers:
theradioham
2010-04-19 07:26:46 UTC
Wikipedia has some info.



One fairly basic method, is to multiply by an irrational number, such as PI or e, constraining the result by a certain modulus, and taking digits from the middle places.



To avoid predictability of a pseudo random generator, the algorithm can be spun while waiting for a key press, so the result is no longer deterministic.



Actually, unless there are some timing constraints, just spinning a simple count while waiting for input can deliver a random result, but with possibly interactions due to interrupt timing.
Curtischoy
2010-04-19 18:57:33 UTC
Most random number generators take the millisecond of the computers clock and use a simple function on it.
Skyshark
2010-04-19 14:13:13 UTC
Put a bunch of numbers into a hat.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...