feat: Initial commit
This commit is contained in:
30
Laboratorio5/fattorizzazionecrivellata.py
Normal file
30
Laboratorio5/fattorizzazionecrivellata.py
Normal file
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user