Ask Question
25 April, 13:37

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Write a function named is_prime that takes an integer argument and returns True if the number is prime and False otherwise. (Assume that the argument is an integer greater than 1, i. e. no need to check for erroneous input.)

+3
Answers (1)
  1. 25 April, 16:20
    0
    This is a function written in Python Programming Language to check whether a given number is prime or not.

    def is_prime (n):

    if (n==1):

    return False

    elif (n==2):

    return True;

    else:

    for x in range (2, n):

    if (n % x==0):

    return False

    return True

    print (is_prime (9))
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Write a function named is_prime ...” in 📙 Engineering if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers