How does a 1-10 simple number generator work?

Recommended Answers

All 9 Replies

is is a random number generator between 1 - 10 ?

yes, without built in fucntions.

This article is a good start.
The most common method used in computer laguages is called the linear congruential method.
Something with multiplication of a seed and modulo a big prime number.
But hey, I'm lazy so all I do if I want a number between 1 and 10:
Random Rnd = new Random();
int numb = Rnd.Next(1,11);

The easiest way would probably be to use this code

Exactly, I am asking what is inside the Random(); fucntion.

Exactly, I am asking what is inside the Random(); fucntion.

What is inside Random(), I think you have to ask that to a guy at MicroSoft
This is a list of possibilities

Actually it's right in the MSDN article on the Random Class

The current implementation of the Random class is based on Donald E. Knuth's subtractive random number generator algorithm. For more information, see D. E. Knuth. "The Art of Computer Programming, volume 2: Seminumerical Algorithms". Addison-Wesley, Reading, MA, second edition, 1981.

Then a simple search on google yielded this thread

What is inside Random class, download ILSpy and see.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.