Showing posts with label prime number checker in python. Show all posts
Showing posts with label prime number checker in python. Show all posts

Wednesday, July 30, 2014

Prime Number Checker in Python

In mathematics we refer a number that is a prime number if the number is greater than one  that has no positive dividend or divisor other than 1 and itself.  For example 7 is considered as prime number primarily because 1 and 7 are its only it positive integer factors, whereas 8 is composite because it has the divisor of 2 and 4.

I wrote this program using Python as my programming language if your find my work useful in your programming assignments and projects using Python you can send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.



Sample Output of Our Program


Program Listing

# Prime Number
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : July 30, 2014 Wednesday

def checking_prime_number(number):
 if number > 1:

   for i in range(2,number):
       if (number % i) == 0:
           print(number,"is not a Prime Number")
           print(i,"times",number//i,"is",number)
           break
   else:
       print(number,"is a Prime Number.")
   
 else:
   print(number,"is not a Prime Number.")

complete = False

while complete == False:

  print("@==================================@")
  print("      Prime Number Checker   ")
  print("@==================================@")
  print("");
  value = int(input("Kindly Enter a Number :=> "))
  print("");
  checking_prime_number(value)
  print("")
  choice = input("Are You Finish?  Y/N: ").lower().strip()
  if choice == "y":
         complete = True
  else:
   print("\n")
  print("Thank You For Using This Program.")
 


DOWLOAD FILE HERE