Created
June 11, 2016 10:30
-
-
Save brettfreer/b88b43de091d2cc8ebbe9a3e2f8e5c1e to your computer and use it in GitHub Desktop.
Euler's Totient
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fractions import gcd | |
def eulers_totient(n): | |
p = 0 | |
for k in range(1, n+1): | |
if gcd(n,k) == 1: | |
p += 1 | |
return p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment