Answers for "isprime in python"

0

isprime function in python

def isPrime(n):
    if n > 1:  
        for i in range(2,n):  
            if (n % i) == 0:  
                return False
        return True
    else:
        return False
Posted by: Guest on March-27-2021
1

isprime in python

def isPrime(n):
    if n==2:
        return True
    if n%2==0:
        return False
    for i in range(3,int(n**0.5)+1):
        if n%i==0:
            return False
    return True
Posted by: Guest on October-08-2021

Python Answers by Framework

Browse Popular Code Answers by Language