title: Reverse that Math function
body: <p>I need to reverse a function with hard Math operations, I'm asking here to check if it's even possible, eventually for help.</p>
  
  <pre><code>    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 &amp; 1) != 0)
                  result = (mult * result) % P;
              X = X &gt;&gt; 1;
              mult = (mult * mult) % P;
          }
          return (UInt32)result;
      }
  </code></pre>
  
  <p><strong>By "Reversing" I mean this: I know G, I know P, I know the result. I need X.</strong></p>
  
  <p>I tried to translate it again this morning while my mind was clear, but I failed. Is it even possible?</p>
  
  <p>Thank you in advance.</p>