import random


def is_prime(num: int, num_rounds: int = 40) -> bool:
    """Probabilistically determine if a given number is a prime.

    This function uses `Miller–Rabin <https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test>`__
    primality test to probabilistically determine if the provided number is prime.

    Args:
        num: prime candidate
        num_rounds: number of iterations inside the algorithm

    Returns:
        whether the number is a prime or not
    """
    if num == 2 or num == 3:  # pragma: no cover
        return True
    if num <= 1 or num % 2 == 0:  # pragma: no cover
        return False

    r, d = 0, num - 1
    while d % 2 == 0:
        r += 1
        d //= 2

    for _ in range(num_rounds):
        a = random.randrange(2, num - 1)
        x = pow(a, d, num)

        if x == 1 or x == num - 1:
            continue

        for _ in range(r - 1):
            x = pow(x, 2, num)
            if x == num - 1:
                break
        else:
            return False

    return True