Solved

# A simple RNG algorithm?

Posted on 2001-07-28

Hi!

I want to learn how RNG:s work, but I have problems grasping the complex examples which I've found.

Could someone please supply an algorithm (preferrably in C or VB) for a *very* simple RNG so I can begin to understand how they work. The rules for the algorithm should be:

-No memory reading and overwriting, it makes the algorithm too complex and I really don't need the security it provides at this point.

-Using mostly logical operations for arithmetics (no mathematical terms to confuse me). If this is impossible, then try to keep it as simple as possible.

-I believe it must be hard to retain randomness in a simple example but if it can be done without making the algorithm too complex then it would be appreciated.

Proper commenting of code will automatically earn the accepted answer 100 points extra. If you post a good comment or snippet regarding this question it might earn you a couple of points too. If this question is too hard for 100 points just say the word and I will raise it to 200.

And no, this is not homework. It's sheer entertainment and a personal challenge.

Marko