import math n = 5 # books available r = 3 # books chosen for the trip combinations = math.comb(n, r) permutations = math.perm(n, r) print(f"C(5,3) = {combinations}") # 10 print(f"Check via nPr / r! = {permutations // math.factorial(r)}") # 10
Click Run to execute this code.