answered 3 years ago
You asked for the discrete logarithm in the ring of integers Z. You meant the following:
sage: discrete_log(Mod(138,401), Mod(3,401), 401-1) 318