Answer to Question #232930 in Python for kaavya

Question #232930

Composite Number

Given an integer N, write a program to find if the given number is a composite number or not. If it is composite, print True or else print False.

Input

The first line of input is an integer N.

Output

The output should be True or False.

Explanation

In the given example,

12 is a composite number as it can be divisible by 1, 2, 3, 4, 6, 12.Therefore, the output should be

True.

Sample Input 1

12

Sample Output 1

True

Sample Input 2

3

Sample Output 2

False




1
Expert's answer
2021-09-03T15:06:41-0400
num = int(input("Enter a number: "))
flag = False
if num > 1:
  
    for i in range(2, num):
        if (num % i) == 0:
            
            flag = True
           
            break
if flag:
    print("True")
else:
    print("false")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS