Skip to content

Instantly share code, notes, and snippets.

@0verflowme
Created January 7, 2021 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0verflowme/81381b2a565f0c9ec5314c96d1dcf271 to your computer and use it in GitHub Desktop.
Save 0verflowme/81381b2a565f0c9ec5314c96d1dcf271 to your computer and use it in GitHub Desktop.
def complex_tot(factors):
phi = 1
for (p, e) in factors:
# Integer prime of this form is a Gaussian prime with norm(p) = p^2
if p % 4 == 3:
phi *= (p**(e-1))**2 * (p**2 - 1)
# Integer prime of this form is factored into two Gaussian primes with norm(P) = p
elif p % 4 == 1:
phi *= (p**(e-1) * (p - 1))**2
return phi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment