[Question]
  [
## What is Permutation Coefficient
Permutation refers to the process of arranging all the members of a given set to form a sequence. The number of permutations on a set of n elements is given by n! , where “!” represents factorial.
The Permutation Coefficient represented by P(n, k) is used to represent the number of ways to obtain an ordered subset having k elements from a set of n elements.
Mathematically,
[![math](https://i.stack.imgur.com/iFQNS.png)](https://i.stack.imgur.com/iFQNS.png)
### Examples:
```
P(10, 2) = 90
P(10, 3) = 720
P(10, 0) = 1
P(10, 1) = 10
```
To Calculate the Permutation Coefficient, you can use the following recursive approach:
`P(n, k) = P(n-1, k) + k * P(n-1, k-1)`
Though, this approach can be slow at times. So Dynamic approach is preferred mostly.
### [Example of Dynamic Approach (Python)](https://tio.run/##fZHLDoIwEEX3fMVdFtEEdEdk5Q@wb1iQ2GpBpqSWhV@PlEdARCdNps2cufNo/bJ3Tae2vQqJWpiqsblVmi5aSMloj9KP4cEdIEUCzkNIbaCgCCanm2AlAkR@NkKTOaiYIRqhSWulMYTjWWKVXiliynUzcx/VlAQrkCQIlyKTpVxlvMi69qN1ong8xd@M7oYDov4VgH2jCyuwW/C983@0ep42u1XXDelqh33cCNsY6kKU8XLYILlRQq/s3NHzaqPIsu3f89v2DQ)
### Input Format
`{n} {k}`
### Output Format
`{PermutationCoefficient}`
### Test Cases
```
INPUT - 100 2
OUTPUT - 9900
INPUT - 69 5
OUTPUT - 1348621560
INPUT - 20 19
OUTPUT - 2432902008176640000
INPUT - 15 11
OUTPUT - 54486432000
```
### Constraints in input
N will always be greater than or equal to K.
### (Not to be confused with Binomial Coefficient)
  
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 5 bytes
```
⊣÷⍥!-
⊣      left argument
 ÷⍥!   divide over factorial, apply factorial to both arguments and then divide
    -  subtract
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/qG9qQACQcAt61DbB2FjB0MjC/P@jrsWHtz/qXaqo@z8NKPyot@9RV/Oj3jWPerccWm/8qG0iUENwkDOQDPHwDP5vaGCgkKZgxGVmCaRMuYxAPENLLkNTEG0IAA "APL (Dyalog Extended) – Try It Online")
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~51~~ ~~23~~ 21 bytes
```
import math
math.perm
```
[Try it online!](https://tio.run/##bYwxCsMwEAR7v8KQxgYR9k7SRfecFAG7kH0INXm9IjUukjQLy86Ovet2Hj5ZaW3PdpY652fdphF3e5XcrOxHXa6@EOB4XeebKjB9r6IujpF8SMIU5RdhONLBcPCsYCDRQyQAf3wUHdGAY@jCfuhQ@wA "Python 3.8 (pre-release) – Try It Online")
---
No builtins:
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 31 bytes
```
f=lambda n,k:k<1or n*f(n-1,k-1)
```
[Try it online!](https://tio.run/##TYxLDgIhEAX3noLEDZiepLv5CBM9zBhDNChDyGw8PQMLo9uqeq98tseatS@1tXh9Le/bfREZ0pwutFaRT1HmiSBNpFqpz7zJKAkRWClxDAHx8KUugB2QtPGOybqfYgQKw7HRHJARPZ2dM4h/e7JANCJr@kEPu2w7 "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~34~~ ~~32~~ 27 bytes
Saved 2 bytes thanks to [Davide](https://codegolf.stackexchange.com/users/100356/davide) who credits [Irratix](https://codegolf.stackexchange.com/users/95940/irratix)'s [JavaScript answer](https://codegolf.stackexchange.com/a/218579/9481)!!!
```
f(n,k){n=k?n*f(n-1,k-1):1;}
```
[Try it online!](https://tio.run/##bZHRaoQwEEXf/YpBENSN1Gi1tdb2ofQrqpQlxlZCs4vxQSp@u51sVNalgQzJnXMnyYQFX4zNc@NKIrxRFuJV@rgJKBEB9Z5oPs2t7OHn2ErXs0YLcGih56pXn/KjggJGGhLYTwxpNuU3uDB4RCAmoDkCuE6uOD6cOet5bcAMmYfIgLpulunCNL5/TCOapOFiZN/HzsfImeCdcdrl8B6VQ/aGM7EJXO9je/E1pw5cfWoraz6gLcyX5TOo9pefGne9j3e3CP6m5HA4XGgPTFvWN0istLbnAlT5Li@2vPg3rzBv/mOvc9S3/twazx0ijWs7NQGnhuBFR0eVEh8vCQgCimwtUkXBq6X6ZE3zHw "C (gcc) – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 bytes
```
Π↑↔ḣ
```
[Try it online!](https://tio.run/##ARkA5v9odXNr///OoOKGkeKGlOG4o////zIw/zE5 "Husk – Try It Online")
```
Π     # product of
 ↑    # the first k elements (k is 2nd argment) of
  ↔   # the reverse of
   ḣ  # 1...n (n is 1st argument)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ḶạP
```
A dyadic Link accepting, the non-negative integers, `n` on the right and `k` on the left which yields `P(n,k)`.
**[Try it online!](https://tio.run/##y0rNyan8///hjm0Pdy0M@P//v/F/QwMA "Jelly – Try It Online")**
### How?
```
ḶạP - Link: k, n          e.g. 3, 10
Ḷ   - lowered range (k)        [0, 1, 2]
 ạ  - absolute difference (n)  [10,9, 8]
  P - product                  720
```
[Answer]
# JavaScript ES6, 25 bytes
```
c=(n,k)=>k?n*c(n-1,k-1):1
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 1 [byte](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
e
```
Builtins ftw ¯\\_(ツ)\_/¯
First input is \$k\$, second input is \$n\$.  
`e` is a builtin for the number of permutations, so \$P(n,k) = \frac{n!}{(n-k)!}\$.
[Try it online](https://tio.run/##yy9OTMpM/f8fiAwtuYwMAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWXC/9T/Ov@jow0NdIxidUCUMYQygFCGYAoiaWapYwqkjICiliBhUx1Dw9hYAA).
[Answer]
# [Whispers v2](https://github.com/cairdcoinheringaahing/Whispers), 34 bytes
```
> Input
> Input
>> 1P2
>> Output 3
```
[Try it online!](https://tio.run/##K8/ILC5ILSo2@v/fTsEzr6C0hAtO2ykYBhiBKP/SEqCAgvH//4YGXMYA "Whispers v2 – Try It Online")
Builtins for the win
[Answer]
# [R](https://www.r-project.org/), ~~26~~ 25 bytes
*Edit: -1 byte by using `scan()` to take input*
```
prod(diff(x<-scan())+1:x)
```
[Try it online!](https://tio.run/##K/r/v6AoP0UjJTMtTaPCRrc4OTFPQ1NT29CqQvO/KZeZJdd/AA "R – Try It Online")
Input in reverse order ( `k` first, then `n`).
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 5 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
‼!-!/
```
Input in the order \$k\text{ }n\$.
[Try it online.](https://tio.run/##y00syUjPz0n7//9Rwx5FXUX9//@NFAwNuIxBhAGIMAQRIDEDLlMFM0suQ0sFI6AoUNgUAA)
**Explanation:**
```
‼      # Apply the following two commands on the stack separately:
 !     #  Take the factorial of the second (implicit) input-integer
  -    #  Subtract the second from the first (implicit) input-integers
   !   # Take the factorial of (n-k) as well
    /  # Integer-divide n! by (n-k)!
       # (after which the entire stack is output implicitly as result)
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 28 bytes
```
param($a,$b)'$a--*'*$b+1|iex
```
[Try it online!](https://tio.run/##jZBNa4QwEIbv/goJadVVF90eSpGAsLTQS1vq3payRDtLt2i1SaQLmt9uNX7Ui2VzSWbeeeeZTJH/AOMfkKYNPpKqKSijmYmpg2PLwNR1V8YKx7Zfn@DcSA0L4GJLOXCd6KGp6e0JK3V15/RVlKJ7dKLvORtrkuBcQCLgXUl3Xi9I5x/zzYL5dnOJ21tw@xd4/SXvCNYsDe/aTXASmtZsKfVVpYKnMouBEV/2DKwADh6bEXxYD6nDekz2lQx4mYqWZl7jox6qKmvWJBKsFVEfoF7gZZIA5wQNbuTCN5pgQ5Ea1yb7l2hbcpFnz/FnK7@FldEpBpnNbdtBNLQcewePHY@gaQgUvCrWHzS4H383Y0tNDpuqH3KWUeHuaJxC8ws "PowerShell – Try It Online")
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell) 7, 43 bytes
```
$f={param($a,$b)$b ?$a*(&$f($a-1)($b-1)):1}
```
no TIO link because TIO still runs on PS 6, which does not support the ternary operator.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 4
```
.P.*
```
[Try it online!](https://tio.run/##K6gsyfj/Xy9AT@v/fw1DAx0FY00A "Pyth – Try It Online")
# Explanation
```
    Q      Implicit input of 2-tuple
  .*       splat
.P         nPr
           Explicit output
```
[Answer]
# x86 Machine Language, 14 bytes
```
86 31 C0 40 29 F7 4E 78 05 47 F7 E7 EB F8 C3   
```
**[Try it online!](https://tio.run/##nVJdSwMxEHzO/opQKCi0pR9YsKAgtX1VqI8FSZNcTckXSU6u/njP7V09W60ovYdjb3ZmspsbFqM0K73trjkve8omqZ/j1iZWUOt8kJkqykcZTJ5YUs5OncwyxZW0aQJ0/xQuEMmKDsUXEGU5qYqYr4gUCuGo4Mn5CRAhsYdfZBPJzIo9WSBgcl0XG@MJkgHbXycEmcreWruVpoYpCzBlmt9Zca@i12yLzj6PL7U1Z1qT0yMjzfmK9Wlcy3DaY2DnU1fiG/dhPl/MnujcBcPSIoWmWx3rA95g1mBMCPTyHToYA8EdAHbT47TGvdZXM@g35AqLiA33OxzvCH@oRmep@mepBv9QnbXY@Pqn6uoX1cn0HQQGoPlJdZB6LHL1RlsH2aAH4bhoiw5ti8tlurldprZY2haU7zzTbB3LrhkNPwA "Assembly (gcc, x64, Linux) – Try It Online")**
The above bytes of code define a function that calculates and returns the Permutation Coefficient, according to the formula given in the challenge. The function accepts two arguments, *n* and *k*, in the `EDI` and `ESI` registers, respectively.\* The result is returned in the `EAX` register, as is conventional.
\* Note that the selection of these two registers is quite flexible. `EDI` and `ESI` were chosen to match some standard C calling conventions, but since this is machine code, they can be changed to any other registers of your choice, except for `EAX` (which is used for the return value) and `EDX` (which is clobbered by the `MUL` instruction).
Ungolfed assembly mnemonics:
```
               PermutationCoefficient:
31 C0             xor    eax, eax               # \ assume
40                inc    eax                    # /  result = 1
29 F7             sub    edi, esi               # n -= k
               Top:                             # <======================\
4E                dec    esi                    # --k                    |
78 05             js     End                    # terminate if k < 0     |
47                inc    edi                    # ++n                    |
F7 E7             mul    edi                    # result *= n            |
EB F8             jmp    Top                    # =======================/
               End:
C3                ret
```
There's nothing especially fancy here. Just machine code at its finest, performing iterative arithmetic with a minimal number of bytes required to encode the instructions. The key innovation is basically just effective use of registers to track the appropriate changes in values of *n* and *k* across iterations, which allows the use of extremely small `INC`rement and `DEC`rement instructions (which can be encoded in only 1 byte). This reduces the number of 2-byte and 3-byte arithmetic operations that must be done inside of the loop, which in turn reduces overall code size. It is probably also a pretty efficient implementation, as far as iterative loops go.
[Answer]
## [R](https://stackoverflow.com/questions/49192128/factorial-with-r), ~~36~~ 35 bytes
Several attempts hitting the same number:
```
function(n,r)choose(n,r)*gamma(r)*r
```
or
```
function(n,r)gamma(r)/beta(n-r+1,r)
```
or yet
```
 function(n,r)"if"(r,n*f(n-1,r-1),1)
```
with
```
 function(n,r)dpois(n-r,1)/dpois(n,1)
  
```
doing even worse (by 1).
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jT6dIMz0xNzdRo0hTPym1JFEjT7dI2xAo@j9Nw9hEx9hIkytNw0THEESZWeqYWWj@BwA "R – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 7 bytes
```
ＩΠ⁻Ｎ…⁰Ｎ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEI6AoP6U0uUTDNzOvtFjDM6@gtMSvNDcptUhDU0chKDEvPVXDQEcBRRwMrP//N7NUMP2vW5YDAA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
      Ｎ Input `k`
    …⁰  Range from `0` to `k-1`
   Ｎ    Input `n`
  ⁻     Subtract i.e. range from `n-k+1` to `n` (inclusive)
 Π      Product
Ｉ       Cast to string
        Implicitly print
```
[Answer]
# [Julia](http://julialang.org/), 20 bytes
nothing fancy here, just applying the basic definition
```
P(n,k)=prod(n-k+1:n)
```
[Try it online!](https://tio.run/##TYxBCsIwEEX3c4pZJhhDp1KhgXiG7ksXQiPElmlJUhAvHxPd@BcP3lv857H6O71yHgSrRdo9bLPg83IiwzInF1NEiyNQg23FpaKpoIIarz120BbvgTokggngsQX06BnJRP924vujSAKW7cFzWvkXR6/MhPaGw59rraUExzNA/gA "Julia 1.0 – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 37 bytes
```
\d+
*
~[".+¶$.("|""L$v`(_*)_ \1
$.'$*
```
[Try it online!](https://tio.run/##K0otycxLNPyvquGe8D8mRZtLi6suWklP@9A2FT0NpRolJR@VsgSNeC3NeIUYQy4VPXUVrf//jRQMDQy4TBXMLLkMLRWMDLgMDRUMTQE "Retina – Try It Online") Link includes test cases. Takes input in the order `k n`. Explanation:
```
\d+
*
```
Convert the inputs to unary.
```
L$v`(_*)_ \1
$.'$*
```
List the numbers from `n-k+1` to `n`, with a `*` suffixed to each.
```
|""
```
Don't separate the results with the default newline.
```
[".+¶$.("
```
Prefix the results with the given string.
```
~
```
Evaluate that as a Retina 1 expression.
Example: For the input `2 100`, there are two matches, where `$.'` takes the values `99` and `100`. The result of the `L` command is therefore
```
.+
$.(99*100*
```
When executed as a Retina program, this then replaces the input with the desired result.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 11 bytes
```
#!/(#-#2)!&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7X1lRX0NZV9lIU1Htf0BRZl5JtLKuXZqDg3KsWl1wcmJeXTVXtaGBgY5RrQ5XtZmljimINjLQMbQEMQxNdQwNa7lq/wMA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
_Ɱ‘P
```
[Try it online!](https://tio.run/##y0rNyan8/z/@0cZ1jxpmBPw/vFz/UdOayP//ow0NdIxidUCUMYQygFCGYAoiaWapYwqkjICiliBhUx1Dw1gA "Jelly – Try It Online")
```
 Ɱ      For each x in 1 .. k,
_       subtract it from n
  ‘     and increment.
   P    Take the product.
```
Alternatively,
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
c×!}
```
[Try it online!](https://tio.run/##y0rNyan8/z/58HTF2v@Hl@s/aloT@f9/tKGBjlGsDogyhlAGEMoQTEEkzSx1TIGUEVDUEiRsqmNoGAsA "Jelly – Try It Online")
```
c       nCk
 ×      times
  !}    k!
```
Bonus solution, 5 bytes, all ASCII: `,_!:/`
[Answer]
# [MATL](https://github.com/lmendo/MATL), 7 bytes
```
Xn0G:p*
```
Because snog :p\*
```
Xn        % compute nchoosek
  0G:p    % compute k!
      *   % multiply
```
[Try it online!](https://tio.run/##y00syfn/PyLPwN2qQOv/fzNLLlMA "MATL – Try It Online")
[Answer]
# [Factor](https://factorcode.org/), ~~28~~ 21 bytes
```
[ [0,b) n-v product ]
```
[Try it online!](https://tio.run/##NY6xDoJAEER7vmJaEyEQY4MfYGhojBWhONdFiHJ33h4khvDteIo2M28mm800irxxy/lUlMccSsSQ4M5O8wO98u1XkmbQ5DujZY1O6Rv/eOTPA4msY@9f1nXaQ/g5sKZwcoiKMoeQU57aaMKEPXaYg2cp0j9kAealQpVuLxvoeIR15jqQRx3aBDXI9NYIrwNjVtQubw "Factor – Try It Online")
Inspired by [Jonathan Allan's Jelly answer](https://codegolf.stackexchange.com/a/218687/78410). Now beats the built-in solution!
Takes two numbers `n k` from the stack, subtracts `0..k-1` from `n`, and computes the product. The product of an empty sequence is 1.
# [Factor](https://factorcode.org/), 27 bytes
```
USE: math.combinatorics
nPk
```
[Try it online!](https://tio.run/##JY0xDoNADAT7e4VfQBOludRRRIMiRXmAY5lgEXzENgWvPxA0K00xsz1SFKvvV9s9MqAZrg5SYGRT/sGEMRzT9ItSSFE/0VC/7Gk2jlhnEw1w/i@sxA631HYZnAyDhnSFy96/51OkMn1EcT8V8qTPsTZ1Aw "Factor – Try It Online")
There's a built-in for this ... except that the import is horribly long.
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 2 bytes
```
∆ƈ
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%E2%88%86%C6%88&inputs=2%0A100&header=&footer=)
Another built-in, like 05AB1E, but not quite as concise.
First input is `k`, second input is `n`.
[Answer]
# Excel, 14 bytes
```
=PERMUT(A1,A2)
```
An Excel built-in.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
o áV l
```
[Try it here](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=byDhViBs&input=MTAKMw)
[Answer]
# [Perl 5](https://www.perl.org/) -MList::Util=reduce, 36 bytes
```
sub f{reduce{$a*$b}$_[0]+1-pop..pop}
```
[Try it online!](https://tio.run/##XZDPT4MwGIbv/hWfrIeBbGk7wMFS9a5zFz3hQpyCkk3alOKPEP518SvEuNhDD@/zvG@Tqlwfwr6QepoCo9QH4CAuII4p3fongCcFiGLMQ5uzRbCMOAujI8qxxWJLebDgMeWULtl5FAWUHo@wEDVmtTDAEVQtdlvkb19TUvlk75P8U7niimSrISUv0ohiZK6NlC4rA0MsrAuX4Mi9Awk4nufdbu5gc33q/JkOPv3bByGGJrzXYLsPFYpdXzc7KFqdPzdPeUsePbLrSJbS7RmbKanmc7y6fjJaRAu2ItoTJAP8sv8eog4mH6V5lY2BcbL/lsqUsqr72fqmrE2S3JvyIEb4Aw "Perl 5 – Try It Online")
[Answer]
# [Java (JDK)](http://jdk.java.net/), 45 bytes
```
(n,k)->{var r=1;for(;k-->0;)r*=n--;return r;}
```
[Try it online!](https://tio.run/##hY@xjoMwDIZ3nsJjUpEIeupJVUTH227qWN2QUoICIUHGIFWIZ@ci7vYs/mXp82e704sW3avf7TAGJOhiL2eyTprZ12SDlyeV1U5PE3xr62HNAKynBo2uG/iCFVzwLRh2hM7/2idXsEVynJ/O1jCRphhLsC8YooXdCa1vHz@gsZ34IYUoM9XOfN5zcVsXjYBVqUxApnohboXieKq8EAobmtEDqm1Xx@BR7u@JmkGGmeQY5eQ8M9KwssgLzlUCKdPIOY18JJG05vOaXxLIOd57Ta265OX/U1u27b8 "Java (JDK) – Try It Online")
Works only for results `<= Integer.MAX_VALUE`.
If `f(_,0)` wasn't a requirement, it could go down one byte:
```
(n,k)->{for(var x=n;k-->1;)n*=x--;return n;}
```
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 16 bytes
```
p(n,k)=n!/(n-k)!
```
[Try it online!](https://tio.run/##FchBCoAgEEDRq4ytHBhJBYMWdRFxMbQIUWSINp3edPf@F36yuaV30Y0KHk2tupmCqrNI/TSDOUGe3N7BZcYCF9eqhYARCWJ01hL4NLjtBGHCj@P2KReGXErYfw "Pari/GP – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 54 bytes
```
lambda n,k:g(n)/g(n-k)
from math import factorial as g
```
[Try it online!](https://tio.run/##Dcg7DoAgDADQ3VN0hAQjMpp4E5eq4RM@JdjF01eXN7z@cqTmxO@HFKznjdBM3oJqevmZs578oAoVOUKqnQaDx4tpJCyADwTpI7U/1WqtcVo@ "Python 2 – Try It Online")
There's a better python solution already.....
]