MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / printNcR

Function printNcR

CodeChef_problems/CHEFINSQ/solution.py:7–23  ·  view source on GitHub ↗
(n, r)

Source from the content-addressed store, hash-verified

5
6#Function of printing nCr values
7def printNcR(n, r):
8 p = 1
9 k = 1
10 if (n - r < r):
11 r = n - r
12 if (r != 0):
13 while (r):
14 p *= n
15 k *= r
16 m = gcd(p, k)
17 p //= m
18 k //= m
19 n -= 1
20 r -= 1
21 else:
22 p = 1
23 return p
24t=int(input())
25for tc in range(t):
26 n,k=map(int,input().split())

Callers 1

solution.pyFile · 0.85

Calls 1

gcdFunction · 0.85

Tested by

no test coverage detected