We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d96029e commit 9fb0cd2Copy full SHA for 9fb0cd2
maths/basic_maths.py
@@ -98,7 +98,17 @@ def euler_phi(n: int) -> int:
98
"""Calculate Euler's Phi Function.
99
>>> euler_phi(100)
100
40
101
+ >>> euler_phi(0)
102
+ Traceback (most recent call last):
103
+ ...
104
+ ValueError: Only positive numbers are accepted
105
+ >>> euler_phi(-10)
106
107
108
109
"""
110
+ if n <= 0:
111
+ raise ValueError("Only positive numbers are accepted")
112
s = n
113
for x in set(prime_factors(n)):
114
s *= (x - 1) / x
0 commit comments