import random


def rabinMiller(num: int) -> bool:
    """Rabin-Miller primality test

    Uses the `Rabin-Miller`_ primality test to check if a given number is prime.

    Args:
         num: Number to check if prime.

    Returns:
        True if num is prime, False otherwise.

    Note:
        * The Rabin-Miller primality test relies on unproven assumptions, therefore it can return false positives when
          given a pseudoprime.

    .. _Rabin-Miller:
        https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
    """
    if num % 2 == 0 or num < 2:
        return False  # Rabin-Miller doesn't work on even integers.
    if num == 3:
        return True
    s = num - 1
    t = 0
    while s % 2 == 0:
        # Keep halving s until it is odd (and use t
        # to count how many times we halve s):
        s = s // 2
        t += 1
    for trials in range(5):  # Try to falsify num's primality 5 times.
        a = random.randrange(2, num - 1)
        v = pow(a, s, num)
        if v != 1:  # This test does not apply if v is 1.
            i = 0
            while v != (num - 1):
                if i == t - 1:
                    return False
                else:
                    i = i + 1
                    v = (v ** 2) % num
    return True