We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ac44461 commit dd1a0c8Copy full SHA for dd1a0c8
maths/prime_factors.py
@@ -77,15 +77,11 @@ def unique_prime_factors(n: int) -> list[int]:
77
i = 2
78
factors = []
79
while i * i <= n:
80
- if n % i:
81
- i += 1
82
- else:
83
- n //= i
84
- if i not in factors:
85
- factors.append(i)
+ if not n % i:
+ factors.append(i)
+ i += 1
86
if n > 1:
87
- if n not in factors:
88
- factors.append(n)
+ factors.append(n)
89
return factors
90
91
0 commit comments