Expand euler phi function doctest (#10401)

This commit is contained in:
Dale Dai
2023-10-13 23:47:08 -07:00
committed by GitHub
parent d96029e13d
commit 9fb0cd271e

View File

@ -98,7 +98,17 @@ def euler_phi(n: int) -> int:
"""Calculate Euler's Phi Function.
>>> euler_phi(100)
40
>>> euler_phi(0)
Traceback (most recent call last):
...
ValueError: Only positive numbers are accepted
>>> euler_phi(-10)
Traceback (most recent call last):
...
ValueError: Only positive numbers are accepted
"""
if n <= 0:
raise ValueError("Only positive numbers are accepted")
s = n
for x in set(prime_factors(n)):
s *= (x - 1) / x