]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Minor algebraic simplification for the totient() recipe (gh-113822)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Mon, 8 Jan 2024 19:16:22 +0000 (13:16 -0600)
committerGitHub <noreply@github.com>
Mon, 8 Jan 2024 19:16:22 +0000 (13:16 -0600)
Doc/library/itertools.rst

index 5c8cc982a89a2cec34e0f7d967f1bd48116bbce1..338a5f9615aae31c5bfde8f004929b3443328d5c 100644 (file)
@@ -1150,7 +1150,7 @@ The following recipes have a more mathematical flavor:
        # https://mathworld.wolfram.com/TotientFunction.html
        # totient(12) --> 4 because len([1, 5, 7, 11]) == 4
        for p in unique_justseen(factor(n)):
-           n = n // p * (p - 1)
+           n -= n // p
        return n