Kiran Divakaran wrote: > Hi All, > > Have a need for a program to give out a unique random number given, provided > it takes a sequence number as an input. > > The requirement is that the value given to this function will be a sequential > number in the range 1-99999999. > > The function which takes this number is expected to return me a unique number > in the same range but random at the same time. > > Please let me know if anyone has used such algorithms in the past. > > > Thanks, > Kiran
That heavily depends on your definition of "random". Rolling your own Random Number Generator (RNG) is NOT recommended. srand()/rand() are decent starting functions. A Psuedo-Random Number Generator (PRNG) is what runs behind those functions with a limited number of round but offer high performance in exchange. Mersenne Twister typically offers significantly improved rounds. And a Cryptographic RNG can be used for cryptography purposes since it uses multiple sources of data for "entropy" (mouse movements, key presses, network data, etc.). A true random number generator is typically based off of a radioactive decay source and/or RF noise (www.random.org). -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
