Files
Laboratori-PY/Laboratorio5/fattorizzazionecrivellata.py
2024-03-22 17:01:42 +01:00

31 lines
492 B
Python

primeList = []
lastIndex = 2
def primeListGenerator():
global primeList, lastIndex
isPrime = True
for primeNumber in primeList:
if lastIndex % primeNumber == 0:
isPrime = False
break
if isPrime:
primeList.append(lastIndex)
lastIndex += 1
n = 12345678901234567890 # int(input("Numero: "))
k = 2
while n > 1:
primeListGenerator()
prime = primeList[-1]
while n % prime == 0:
n = int(n/prime)
print(prime)