I'm trying to recover the internal state of a custom RNG in order to predict the next state. The formula to compute the next state is as follow :
$nextState = (state * A + B) \mod p$
The value of p is the 9th mersenne prime ( $2^{61}-1$ )
A and B are large static integer ( they don't change between iterations )
I'm able to retrieve the values for the current states, but in order to predict the next one I need to find the values for parameters A and B
I've tried to generalize the equation as : $S_{i+1} = (S_i * A + B) \mod p$
If i understood modulo operation correctly, $S_{i+1}$ is the remainder of $(S_i * A + B) // p$
I don't know where to go from there, any resources or explanation to understand what I should be doing would be really appreciated.