Ask Question
3 July, 12:50

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.)

+4
Answers (1)
  1. 3 July, 15:42
    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?
Find 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 you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers