Find the discrete logarithm
C (gcc), 59 53 51 bytes
Saved 6 bytes thanks to the man himself Arnauld!!!
Saved 2 bytes thanks Dominic van Essen!!!

p;x;f(a,b,m){for(p=a,x=1;p-b&amp;&amp;++x&lt;m;)p=p*a%m;x%=m;}

Try it online!
Inputs positive integers \$a,b,m\$ with \$a,b&lt;m\$.
Outputs a positive integer \$x\$ such that \$a^x\equiv b\ (\text{mod}\ m)\$ or \$0\$ if no such \$x\$ exists.