Advertisement
GeorgiLukanov87

finding_prime_num

Apr 3rd, 2022
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. # Python program to display all the prime numbers within an interval
  2. lower = 1
  3. upper = 7
  4. print("Prime numbers between", lower, "and", upper, "are:")
  5. for num in range(lower, upper + 1):
  6.     # all prime numbers are greater than 1
  7.     if num > 1:
  8.         for i in range(2, num):
  9.             if (num % i) == 0:
  10.                 break
  11.         else:
  12.             print(num)
  13. +++++++++++++++++++++++++++++++++++++++++++++++++
  14. # 2nd Code to find Prime Number
  15. for number in range(2, 7 + 1):
  16.     bol = True
  17.     for i in range(2, number - 1):
  18.         if number % i == 0:
  19.             print(number, "is not prime number")
  20.             bol = False
  21.             break
  22.     if bol:
  23.         print(number, "is a prime number")
  24.  
  25. +++++++++++++++++++++++++++++++++++++++++++++++++
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement