我正在查看一个公式:
Xn+1 = (a Xn + c)(mod m)
where "n" is number of values which can be from 1 to 1700. "X" is the number. (n+1 and n are both as sub-scripts)
我试图找到伪随机数列表的 future 可能结果(每个数字最多有 6 位数字,并且可以具有从 000001 到 999999 的值)。
我知道 Xn+1 和 Xn 的值;对于“m”,我使用值“1000000”或“999999”,因此结果始终为 6 位或更少。
我需要找出“a”的值。
for reference: Xn=663354 and Xn+1=142516 OR 211941 OR 453794 OR 512535 OR 704928 (do not know the order of these numbers but can try them one by one myself, if i just can know how to get a value of "a" in the above equation)
如果有人可以提出其他建议,我需要解决这个等式或任何其他问题。
我不擅长编程;我目前正在使用 MS Excel
来解决这个问题。
但能看懂一点VB
的代码。
谢谢你的期待。
最佳答案
好吧,如果我理解得很好,你想确定循环关系中的参数 a 和 c。但是你只有一个方程的解。您的系统未定,您需要 3 个值 Xn+2、Xn+1 和 Xn。 ( http://en.wikipedia.org/wiki/Underdetermined_system )
如果您知道 c,那么这很明显:您需要求解一个线性方程。
关于algorithm - 如何解决余数函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16998425/