According to my understanding, setting srand with a specific seed calls a sequence of calls to rand () to get the same series of numbers every time for that particular seed:
For instance:
srand(seed1);
rand() // firstnumber (e.g.: 42)
rand() // second number (e.g: 17)
srand(seed1)
rand() // first number (same as above (42))
rand() // second number (same as above (17))
Is there a way to get the nth number in a sequence directly without calling rand () n times?
For example, if I want the 17th random number in a series, I want to get the number in one call, instead of calling rand () 17 times.
I cannot precompile and save values
EDIT: I watched this article:
https://mathoverflow.net/questions/104915/pseudo-random-algorithm-allowing-o1-computation-of-nth-element
, , , , , , .
EDIT: , "" n- , , rand , . , , , , . .
EDIT: PRNG. , , , . , . .
: - . n- O (1) . n- , , n- O (1)