Last active
August 29, 2015 14:03
-
-
Save nuit/0ea76c7f9d6081504ebd to your computer and use it in GitHub Desktop.
Crivo de Eratóstenes, Função Totiente de Euler
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 __future__ import division | |
def phi(i): | |
l=[] | |
n=1 | |
multiples = set() | |
for p in range(2, i+1): | |
if p not in multiples: | |
multiples.update(range(p*p, i+1, p)) | |
if i%p==0: | |
j=(p-1)/p | |
l.append(j) | |
for j in l: | |
n*=j | |
n=i*n | |
print n | |
phi(420) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment