Created
October 19, 2022 19:54
-
-
Save ZhouYang1993/bf7d3fe46ba75d03fe344fb11271618b to your computer and use it in GitHub Desktop.
prime_factorization_in_python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prime_factorization(num: int): | |
k = 2 | |
factors = [] | |
while k * k <= num: | |
while num % k == 0: | |
factors.append(k) | |
num //= k | |
k += 1 | |
if num > 1: | |
factors.append(num) | |
return factors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment