Modules and imports · 10 / 16 Exercise Medium

Combinations and permutations

Objective

Create a Python program that calculates in how many ways k elements can be chosen from n, with and without regard to order.

Instructions

  • Read two integers, n and k (with 0 ≤ k ≤ n), one per line.
  • Show Combinations: C, the ways to choose without regard to order (math.comb).
  • Show Permutations: P, the ways to choose and arrange (math.perm).
Input
5
2
Output
Combinations: 10
Permutations: 20

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise