Random algorithm with biggest sequence that never repeats
If you don't want to follow Yuval's advice :), Mersenne Twister algorithm is a good random number generator and has a quite simple implementation (period of $2^{19937}−1$). See Wikipedia page for quick highlights on advantages/disadvantages. There are also many open source implementations in many programming languages.

For technical details and in-deep analysis of the algorithm see M. Matsumoto's articles that are available on his page.