Write a Python function to Find if a Number is Prime or Not Prime


Topic: Write a Python function to Find if a Number is Prime or Not Prime

Solution

def check(n, div = None):
    if div is None:
        div = n - 1
    while div >= 2:
        if n % div == 0:
            print("Number not prime")
            return False
        else:
            return check(n, div-1)
    else:
        print("Number is prime")
        return 'True'



List all Python Programs