Take the 2-minute tour ×  I need to reverse a function with hard
Math operations, I'm asking here to check if it's even possible,
eventually for help.      public static UInt32 Func_4(UInt32 P,
UInt32 X, UInt32 G)         UInt64 result = 1;         UInt64
mult = G;         if (X == 0)             return 1;
while (X != 0)             if ((X & 1) != 0)
result = (mult * result) % P;             X = X >> 1;
mult = (mult * mult) % P;         return (UInt32)result;  By
"Reversing" I mean this: I know G, I know P, I know the result.
I need X.  I tried to translate it again this morning while my
mind was clear, but I failed. Is it even possible?  Thank you in
advance.  share|improve this question What are your expected
inputs to the inverse? Which of P, X, and G are you looking to
get back? –  Ben Alpert Apr 24 '09 at 4:34 It would help if you
show the algorithm you hope to do. Also, if you know the result
and don't know X, then why pass in X? Pass in the result as a
parameter. – 