AnsweredAssumed Answered

Python program to print all Prime numbers in an Interval

Question asked by suraj kumar on May 12, 2020
Latest reply on May 13, 2020 by Stefanie Sanders

def PrimeNumber_interval(start,end):
   print('prime number between %d and %d:'%(start,end))
   for i in range(start, end+1):
      for j in range(2,i):
         if i % j == 0:
               break
         else:
            print(i, end = ',')

PrimeNumber_interval(11,25)

 

output:  

  • prime number between 11 and 25: 11,13,17,19,23,

    NOte: Question is, i don't wanted to comma after 23 in output. How to solve it

Python program to print all Prime numbers in an Interval

Outcomes