Python
# Program to check if a number is composite
n = int(input("Enter an integer: "))
if n <= 1:
print(n, "is neither prime nor composite")
else:
is_composite = False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
is_composite = True
break
if is_composite:
print(n, "is a composite number")
else:
print(n, "is not a composite number (it is prime)")Output
Enter an integer: 9 9 is a composite number
We look for any divisor between 2 and √n; if found, the number is composite.