Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def esPrimo(n: int) -> bool:
- def menorDivisorDesde(n: int, m: int = 2) -> int:
- if n == 1 or n == m: return n
- if n%m == 0: return m
- return menorDivisorDesde(n, m+1)
- return n != 1 and n == menorDivisorDesde(n)
- def factorizacion(n: int) -> list:
- def factorizacionAux(n: int, m: int = 2) -> list:
- if n == 1: return []
- if n%m == 0 and esPrimo(m): return [m, *factorizacionAux(n//m, m)]
- return factorizacionAux(n, m+1)
- return factorizacionAux(n)
- if __name__ == '__main__':
- print(factorizacion(2*2*2*5*5*11*11*13*19)) # 5977400
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement