Artificial intelligent assistant

Pseudorandom Number Generator Back in the ancient times, we used 997 * modulo 1000000 to generate pseudorandom numbers. Each number became the seed for the next number. It was fast, it wasn't too bad statistically, and was useful for many problems we ran on programmable calculators like the HP-41. My problem: given a six-digit random number, is it possible to calculate the previous random number from which it was generated? If so, how? What if only five digits are retained instead of six?

Yes.

If $a_{n+1}=997a_n\bmod 1000000$, then $a_n=444333a_{n+1}\bmod 1000000$. This is because $997\cdot 444333=443000001$.

If the last digit of $a_{n+1}$ is unknown, you obtain 10 possible values of $a_n$ accordingly, one differing from the next by $1003$ (why?)

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy cd4e8e6d663434a048f8917ac961d9e5