Advertisement
MRtecno98

TechMath V.1.0.0

May 20th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. #This is ANOTHER core of core and implements math functions in python
  2. #Requires Techcore V.1.2.0
  3. #Or use in standalone version
  4.  
  5. def Fattoriale(num) :
  6.     fattoriale = 1
  7.     contatore = 1
  8.     while not contatore > num :
  9.         fattoriale*=contatore
  10.         contatore+=1
  11.     return fattoriale
  12.  
  13. def isPrime(num) :
  14.     counter = num - 1
  15.     while not counter == 1 :
  16.         if num % counter == 0 :
  17.             return False
  18.         counter-=1
  19.     return True
  20.  
  21. def calculatePrimes(maxnum) :
  22.     counter = 2
  23.     theresprimes = False
  24.     primes = 0
  25.     while not counter == maxnum :
  26.         if isPrime(counter) :
  27.             print("Trovato numero primo: " + str(counter))
  28.             primes+=1
  29.             theresprimes = True
  30.         counter+=1
  31.     if not theresprimes :
  32.         print("Non è stato trovato nessun numero primo.")
  33.     else :
  34.         print("Trovati " + str(primes) + " numeri primi.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement