Posts

Showing posts with the label prime number or composite number program

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

Image
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.  A  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...