Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This is ANOTHER core of core and implements math functions in python
- #Requires Techcore V.1.2.0
- #Or use in standalone version
- def Fattoriale(num) :
- fattoriale = 1
- contatore = 1
- while not contatore > num :
- fattoriale*=contatore
- contatore+=1
- return fattoriale
- def isPrime(num) :
- counter = num - 1
- while not counter == 1 :
- if num % counter == 0 :
- return False
- counter-=1
- return True
- def calculatePrimes(maxnum) :
- counter = 2
- theresprimes = False
- primes = 0
- while not counter == maxnum :
- if isPrime(counter) :
- print("Trovato numero primo: " + str(counter))
- primes+=1
- theresprimes = True
- counter+=1
- if not theresprimes :
- print("Non è stato trovato nessun numero primo.")
- else :
- print("Trovati " + str(primes) + " numeri primi.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement