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