Skip to content

Commit 0b31a50

Browse files
[3.12] Minor algebraic simplification for the totient() recipe (gh-113822) (gh-113823)
1 parent 7390dff commit 0b31a50

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Doc/library/itertools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ The following recipes have a more mathematical flavor:
11421142
# https://mathworld.wolfram.com/TotientFunction.html
11431143
# totient(12) --> 4 because len([1, 5, 7, 11]) == 4
11441144
for p in unique_justseen(factor(n)):
1145-
n = n // p * (p - 1)
1145+
n -= n // p
11461146
return n
11471147

11481148

0 commit comments

Comments
 (0)