Euler's Totient · Nhóm: Số học
Hàm Euler phi (Euler's Totient), nhóm Số học.
def phi(n):
result = n
p = 2
while p * p <= n:
if n % p == 0:
while n % p == 0:
n //= p
result -= result // p
p += 1
if n > 1:
result -= result // n
return result
Mở trang để xem mô phỏng từng bước và xuất slide bài giảng.