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.
in the given example 12345678911 and the output should be True
num = int(input("Enter a number: "))
# define a flag variable
flag = False
# prime numbers are greater than 1
if num > 1:
# check for factors
for i in range(2, num):
if (num % i) == 0:
# if factor is found, set flag to True
flag = True
# break out of loop
break
# check if flag is True
if flag:
print("True")
else:
print("false")
Comments
Leave a comment