File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1049,11 +1049,10 @@ The following recipes have a more mathematical flavor:
1049
1049
# factor(1_000_000_000_000_403) --> 1000000000000403
1050
1050
for prime in sieve(math.isqrt(n) + 1):
1051
1051
while True:
1052
- quotient, remainder = divmod(n, prime)
1053
- if remainder:
1052
+ if n % prime:
1054
1053
break
1055
1054
yield prime
1056
- n = quotient
1055
+ n //= prime
1057
1056
if n == 1:
1058
1057
return
1059
1058
if n > 1:
@@ -1354,6 +1353,12 @@ The following recipes have a more mathematical flavor:
1354
1353
>>> set (sieve(10_000 )).isdisjoint(carmichael)
1355
1354
True
1356
1355
1356
+ >>> list (factor(99 )) # Code example 1
1357
+ [3, 3, 11]
1358
+ >>> list (factor(1_000_000_000_000_007 )) # Code example 2
1359
+ [47, 59, 360620266859]
1360
+ >>> list (factor(1_000_000_000_000_403 )) # Code example 3
1361
+ [1000000000000403]
1357
1362
>>> list (factor(0 ))
1358
1363
[]
1359
1364
>>> list (factor(1 ))
You can’t perform that action at this time.
0 commit comments