Combinations nCr Small

Combinations nCr Small

Medium Computer Mathematics Combinatorics 27 views
Explanation Complexity

Problem Statement

Compute nCr for small n (n

Input Format

Two integers n r.

Output Format

One integer.

Example

5 2
10

Constraints

0

Input / Output Format

Input Format
Two integers n r.
Output Format
One integer.
Constraints
0

Examples

Input:
5 2
Output:
10

Example Solution (Public)

Computer Mathematics
Use multiplicative formula: res=1; for i=1..r res=res*(n-r+i)/i using integer exact division.

Official Solution Code

Use multiplicative formula: res=1; for i=1..r res=res*(n-r+i)/i using integer exact division.
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.