-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem72_py.txt
More file actions
46 lines (27 loc) · 799 Bytes
/
Copy pathproblem72_py.txt
File metadata and controls
46 lines (27 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
""" euler toitent function"""
def phi(n) :
result = n
p = 2
while p * p<= n :
if n % p == 0 :
while n % p == 0 :
n = n // p
result = result * (1.0 - (1.0 / float(p)))
p = p + 1
if n > 1 :
result = result * (1.0 - (1.0 / float(n)))
return int(result)
p = 2
while p * p<= n :
if n % p == 0 :
while n % p == 0 :
n = n // p
result = result * (1.0 - (1.0 / float(p)))
p = p + 1
if n > 1 :
result = result * (1.0 - (1.0 / float(n)))
return int(result)
result = 0
for i in range(2, 1000001):
result += phi(i)
print(result)