Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- upper_bound = int(input("Upperbound: "))
- primes = []
- for num in range(2, upper_bound + 1):
- # Controlliamo se num è primo
- is_prime = True
- for divisor in range(2, int(math.sqrt(num)) + 1):
- if(num % divisor == 0):
- # Se sono qui anche solo una volta allora non ho un numero primo
- is_prime = False
- break
- if(is_prime):
- primes.append(num)
- print(primes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement