Okay, here's the "source code" to an ridiculously primitive random number generator for the Atari 2600 Basic Programming cartridge.
Code:
1 S<-9
2 M<-31
3 I<-5
4 F<-3
5 S<-(FxS+I) Mod M
6 Hor1<-S
7 Goto 5
In case you haven't seen it before, the Mod operator returns the integer remainder when the left operand is divided by the right. So 5 Mod 3 would be 2.
Line 5 is the brains of the equation.
The variables F, M, and I are the parameters. Changing these will alter the length of the sequence before it starts to repeat. Also, the value of M will determine the maximum value that can be generated.
Variable S is the seed. The equation just takes FxS+I, finds the remainder when divided by M, then puts that back into S, which is the seed value. So the seed is basically used to find its next value.
There are a lot better ways to generate random numbers than this, but it's the only source code I've got on hand right now. Heh. It still illustrates the basic principles, though.