mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 18:38:39 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
8bd2067393
commit
bb34d5d215
@ -1,15 +1,16 @@
|
|||||||
from math import ceil, sqrt
|
from math import ceil, sqrt
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
def primeproduct(n: int, x: list = []):
|
def primeproduct(n: int, x: list = []):
|
||||||
'''
|
"""
|
||||||
>>> primeproduct(868)
|
>>> primeproduct(868)
|
||||||
[2, 2, 7, 31]
|
[2, 2, 7, 31]
|
||||||
>>> primeproduct(9039423423423743)
|
>>> primeproduct(9039423423423743)
|
||||||
[2, 2, 7, 31, 719, 12572216166097]
|
[2, 2, 7, 31, 719, 12572216166097]
|
||||||
>>> primeproduct(0.02)
|
>>> primeproduct(0.02)
|
||||||
[]
|
[]
|
||||||
'''
|
"""
|
||||||
if n < 1:
|
if n < 1:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@ -30,7 +31,6 @@ def primeproduct(n : int, x : list = []):
|
|||||||
flag = 1
|
flag = 1
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Handle factor 2 separately
|
# Handle factor 2 separately
|
||||||
while n % 2 == 0: # only 2 is even prime
|
while n % 2 == 0: # only 2 is even prime
|
||||||
@ -53,6 +53,7 @@ def primeproduct(n : int, x : list = []):
|
|||||||
|
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
# faster than https://github.com/sourabhkv/Python/blob/master/maths/prime_factors.py approx 2x
|
# faster than https://github.com/sourabhkv/Python/blob/master/maths/prime_factors.py approx 2x
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import doctest
|
import doctest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user