P=Q
If p=q then N=pq=p2 and you can use function such as isqrt in Python to retrieve p.
Note that in the situation N=p2, ϕ(N)=(p−1)2 due to the full definition of Euler's totient function:
ϕ(n)=np∣n∏(1−p1)
The key here is that p∣n are distinct prime factors, so we would only use p once in the equation:
ϕ(n)=n(1−p1)=n−p
Last updated
Was this helpful?