0
Prime numbers
Could someone explain to me in python how I could write a code that returns the prime number between two numbers?
4 Respostas
+ 1
Suppose you want to find prime numbers between 1 and 10
So it should be
a=1
b=10
for i in range((a+1),b):
 if i%2!=0 and i%3!=0 or i/2==1 or i/3==1:
  print(i)
0
this is not exactly what i was asking. i want to write a program the can tell if either 25 or 7 are prime
0
just edit the code above, start with input, like
a=input()
b=a//2 # actually forgot the notation, but basically works like 25//2=12, it's the partner of modulo
prime=0
if a=2 or a=3:
    print('prime')
elif a<2:
    print('not prime')
else:
    for i in range (2, b):
      if a%i=0
         print('prime')
         prime=1
        break
if prime=0:
    print('not prime')



