Prime Number Checker

  • Share this:

Code introduction


Determine whether a number is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.


Technology Stack : Built-in functions (range, int, **)

Code Type : Function

Code Difficulty : Intermediate


                
                    
def is_prime(num):
    if num <= 1:
        return False
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    return True