We can reduce your problem to solving a linear equation modulo an integer. That way we can avoid functions like Minimize
.
If a primitive root exists for the modulus, we can take discrete logarithms of both sides and easily solve for r
. This following code finds the smallest positive r
such that (b^r - c)/mod ∈ Integers
.
HasPrimitiveRootQ[n_Integer?Positive] :=
n < 8 || (OddQ[n] && PrimePowerQ[n]) || (OddQ[n/2] && PrimePowerQ[n/2])
HasPrimitiveRootQ[_] = False;
MinExponent[{b_, c_, mod_?HasPrimitiveRootQ}, r_] := Module[{g,dlhs,drhs,phi,gcd,sol},
g = PrimitiveRoot[mod];
dlhs = MultiplicativeOrder[g, mod, {b}];
drhs = MultiplicativeOrder[g, mod, {c}];
phi = EulerPhi[mod];
gcd = GCD[dlhs, drhs, phi];
{dlhs, drhs, phi} /= gcd;
Print["Solving ", Mod[dlhs r, phi] == Mod[drhs, phi]];
sol = Solve[Mod[dlhs r, phi] == Mod[drhs, phi] && 0 < r <= phiMod[drhs*PowerMod[dlhs, r-1, Integers];
If[sol =!= {}phi],
r == Min[r /. sol]phi,
False
]1]
]
And your example reduces to solving a linear equation mod 3:
MinExponent[{10, 1, 37}, r]
Solving Mod[2r, 3] == 0
r == 3