Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

identify if a number is prime

def prime():
  prime=True
  while True:
   for i in range(2,x-1):
      y=x%i
      if (y==0):
        prime=False
   break
  if (x==0) or (x==1):
    print(x , "is not a prime number")
  elif (prime==True):
    print(x , "is a prime number")
  else:
    print(x , "is not a prime number")
x=int(input("Enter a number:"))
prime()
 
PREVIOUS NEXT
Tagged: #identify #number #prime
ADD COMMENT
Topic
Name
6+7 =