Are there any way to predict some number of the Random class without going through a loop of rnd.NextDouble()?
i am using this code now:
Random rnd = new Random(SOME_STATIC_SEED);
//I need to get the 1000000'th random number:
for (ulong i = 0; i < 1000000; i++)
//I need to avoid this loop and get the result in a linear time!
{
rnd.NextDouble();
}
double iNeedThisNumber = rnd.NextDouble();
How can i get it without the loop? i need the same exact number given using the algorithm of System.Random class of .Net!
Allegedly solved:
This is my code!!
public static ulong GetNumberFromSequence(int seq)
{
Random rnd = new Random(seq);
return (ulong)(rnd.NextDouble() * 99999999999999) ^ (ulong)seq;
}
See if this works for you
Use the seed for the desired index in the random-number generator, and then pick the first generated number.