num = 10
for i in range(2,num+1):
for j in range(2,i):
if(i%j == 0):
break
else:
print(i)
#prime number gen
nums=[]
max=10000
class N:
def crazy():
for i in range(max):
nums.append(True)
nums[0]=False
nums[1]=False
for index in range(max):
if nums[index]:
current_multiple = 2
while index*current_multiple < max:
nums[index*current_multiple ]= False
current_multiple += 1
for index in range(max):
if nums[index]:
print(f"----> {index} is a prime #")
N.crazy()
# Thanks to https://www.codegrepper.com/profile/farid
# Just tune his answer into easy to use function
def prime_numbers(start_num, end_num):
for number in range(start_num , end_num + 1):
is_prime = True
for counter in range(2,number):
value = number % counter
if value == 0:
is_prime = False
break
if is_prime == True:
print(number)
def is_prime(n):
for i in range(2,n):
if (n%i) == 0:
return False
return True
lower = int(input("Enter lower range: "))
upper = int(input("Enter upper range: "))
for num in range(lower,upper + 1):
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
else:
print(num)