P21759 [GeeksforGeeks] Npr4253
普及-
题目描述

Write a program to calculate {n}P^{r}. represents n permutation r and value of }P^{r{n}P^{r }is (n!) / (n-r)!.
Example 1:
Input: n = 2, r = 1
Output: 2
Explaination: 2!/(2-1)! = 2!/1! = (2*1)/1 = 2.
Example 2:
Input: n = 3, r = 3
Output: 6
Explaination: 3!/(3-3)! = 3!/0! = 6/1 = 6.
Your Task:
You do not need to read input or print anything. Your task is to complete the function nPr() which takes n and r as input parameters and returns
.}P^{r
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n, r ≤ 20

输入格式

见题面

输出格式

见题面

样例输入
n = 2, r = 1
样例输出
2