Skip to content

Instantly share code, notes, and snippets.

@ZhouYang1993
Created October 19, 2022 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZhouYang1993/bf7d3fe46ba75d03fe344fb11271618b to your computer and use it in GitHub Desktop.
Save ZhouYang1993/bf7d3fe46ba75d03fe344fb11271618b to your computer and use it in GitHub Desktop.
prime_factorization_in_python
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