How do random number generator works? (for example in C/C++ Java)
How can I write my own random number generator? (for example in C/C++ Java)
One of the things to keep in mind is that there are no 'true' random number generators. They just generate numbers that look random to us mere mortals.
One of the easiest examples of this (to implement, as well) is the Linear congruential generator. Sure, the numbers look unpredictable to you and me, but they're actually evenly spaced within a finite field.
Of course, some generators, like Blum Blum Shub aren't predictable for an outsider even if he applies serious mathematical skills and computing power to the task, but at the fundamental level, random number generators aren't random; they're regular and predictable.