import math n = 6 # runners in the race r = 3 # medal positions: gold, silver, bronze permutations = math.perm(n, r) manual = math.factorial(n) // math.factorial(n - r) print(f"P(6,3) = {permutations}") # 120 print(f"Manual check: {manual}") # 120
Click Run to execute this code.