mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 01:00:15 +00:00
Expand euler phi function doctest (#10401)
This commit is contained in:
parent
d96029e13d
commit
9fb0cd271e
|
@ -98,7 +98,17 @@ def euler_phi(n: int) -> int:
|
||||||
"""Calculate Euler's Phi Function.
|
"""Calculate Euler's Phi Function.
|
||||||
>>> euler_phi(100)
|
>>> euler_phi(100)
|
||||||
40
|
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
|
s = n
|
||||||
for x in set(prime_factors(n)):
|
for x in set(prime_factors(n)):
|
||||||
s *= (x - 1) / x
|
s *= (x - 1) / x
|
||||||
|
|
Loading…
Reference in New Issue
Block a user