Ask Question
1 March, 21:29

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

+1
Answers (1)
  1. 1 March, 21:31
    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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers