Calculate number of combinations

math.comb() function

import math

def calculate_combinations(n, k):
    return math.comb(n, k)

n = 5
k = 3

num_combinations = calculate_combinations(n, k)

print("Number of combinations:", num_combinations)

Leave a Reply

Your email address will not be published. Required fields are marked *