我正在尝试获取产生此随机数的原始值。
Random rand = new Random(295);
int nextInt = 0;
for (int n = 0; n < 78801 + 1; n++) {
nextInt = rand.nextInt(500000);
}
System.out.println(nextInt);//499429
值(499429)由种子(295)产生,它是第78801个nextInt。根据所附的链接,我已经做了很多研究,LCG是可逆的。我该如何在Java中反转它,以便仅使用种子值和输出我将获得第n个值?
Making a customizable LCG that travels backward and forward
Reversible pseudo-random sequence generator
pseudo random distribution which guarantees all possible permutations of value sequence - C++
Reversible Linear Congruential Generator
Cracking a linear congruential generator
Cracking Random Number Generators - Part 1
Reverse engineering the seed of a linear congruential generator