]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] Minor algebraic simplification for the totient() recipe (gh-113822) (gh-113823)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 8 Jan 2024 19:22:42 +0000 (20:22 +0100)
committerGitHub <noreply@github.com>
Mon, 8 Jan 2024 19:22:42 +0000 (19:22 +0000)
Doc/library/itertools.rst

index a0181612d5bb67a679dbe6ca377560ab2c7361d2..67dc8f6d875f68f379d12995a94531690a71918e 100644 (file)
@@ -1142,7 +1142,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