import math


def num_k_of_n(n: int, k: int) -> int:
    """Return number of combinations of k elements out of n."""
    if k > n:
        return 0
    if k == n:
        return 1
    return math.factorial(n) // (math.factorial(k) * math.factorial((n - k)))