Answer to Question #220256 in Python for aakash

Question #220256

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



1
Expert's answer
2021-07-25T10:11:40-0400


def composite(number):
 
    
    if (number <= 1):
        return False
    if (number <= 3):
        return False
 
    
    if (number % 2 == 0 or number % 3 == 0):
        return True
    x = 5
    while(x * x <= n):
         
        if (number % x == 0 or number % (x + 2) == 0):
            return True
        x = x + 6
         
    return False
 
n = int(input("Enter integer N\n "))
 
print("True") if(composite(n)) 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
APPROVED BY CLIENTS