user
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.

### Instruction:
Refactor the following code to optimize it for speed and ease of use.

### Input:
def check_prime(num):
    for n in range(2, num):
        if num % n == 0:
            return False
    return True

### Response:
assistant
def check_prime(num):
    if num < 2:
        return False

    # check only odd numbers
    if num % 2 == 0:
        return False
    
    for n in range(3, int(num**0.5)+1, 2):
        if num % n == 0:
            return False
    return True