Program to find out whether a given number is prime number or not in python[using break statement]

PRIME NUMBER OR COMPOSITE NUMBER

  • Prime and composite numbers are the two types of numbers, that differ based on the number of factors they have.
  •  A prime number is the one that has only two factors .
  • A composite number has more than two factors. 
  • factor is a value, that can divide a number or an expression evenly.
  • A prime number is the one which has exactly two factors, which means, it can be divided by only “1” and itself. But “1” is not a prime number.
  • A composite number has more than two factors, which means apart from getting divided by the number 1 and itself, it can also be divided by at least one integer or number. We don’t consider ‘1’ as a composite number.

CODING OF THE PROGRAM




num=int(input("Enter a number to check"))
for i in range(2,num):
       if  num%i==0:
              print(num," is a Composite  number")
              break
else:
       print(num," is a prime number")

OUTPUT OF THE PROGRAM




                                               
THANK YOU😊







Comments

Popular posts from this blog

How to display BMI(Body mass index )using python program

How to display Floyd's triangle in python program

To display whether the given number is perfect or not in Python