There is a variable first_variable
which is always a mod of some number, mod_value
.
In every step first_variable
is multiplied with some number second_variable
.
And the range of all three variables is from 1
to 10^18
.
For that I build a formula,
first_variable = ((first_variable%mod_value)*(second_variable%mod_value))%mod_value
But this gives a wrong answer,
For example, If first_variable and second_variable
is (10^18)-1
and mod_value = 10^18
Please suggest me method, so that first_variable
will always give right answer.