[Question]
  [
Suppose we have two different types of coin which are worth relatively prime positive integer amounts. In this case, it is possible to make change for all but finitely many quantities. Your job is to find the largest amount that cannot be made with these two types of coin.
## Task
Input: A pair of relatively prime integers \$(a,b)\$ such that \$1<a<b\$.
Output: The largest integer that cannot be expressed as \$ax+by\$ where \$x\$ and \$y\$ are nonnegative integers.
## Scoring:
This is code golf so shortest answer in bytes wins.
## Example:
Input \$(3,11)\$ 
\$4\cdot 3- 1\cdot 11=1\$, so if \$n\geq 22\$ we can write \$n=q\cdot 3 + 2\cdot 11 +r\$ where \$q\$ is the quotient and \$r\in\{0,1,2\}\$ the remainder after dividing \$n-22\$ by \$3\$. The combination \$(q+4r)\cdot 3 + (2-r)\cdot 11 = n\$ is a nonnegative combination equal to \$n\$. Thus the answer is less than \$22\$. We can make \$21=7\cdot 3\$ and \$20=3\cdot 3 + 1\cdot 11\$ but it's impossible to make \$19\$ so the output should be \$19\$.
## Test Cases:
```
[ 2,  3] => 1
[ 2,  7] => 5
[ 3,  7] => 11
[ 3, 11] => 19
[ 5,  8] => 27
[ 7, 12] => 65
[19, 23] => 395
[19, 27] => 467
[29, 39] => 1063
[ 1,  7] => error / undefined behavior (inputs not greater than one)
[ 6, 15] => error / undefined behavior (not relatively prime).
[ 3,  2] => error / undefined behavior (3 > 2)
[-3,  7] => error / undefined behavior (-3 < 0)
```
  
[Answer]
# [J](http://jsoftware.com/), ~~7~~,~~6~~ 3 bytes
-1 byte thanks to FrownyFrog ! 
-3 bytes thanks to Grimmy!
```
*-+
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/tXS1/2tyKXClJmfkKxgppCkYI5jmEKYxKtPQEMI2BbItIExzkLARhG1oCeQYGSNzoJqNQBxjy/8A "J – Try It Online")
```
     -    subtract
      +   the sum of the arguments
    *     from their product
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 bytes
```
←¤*←
```
[Try it online!](https://tio.run/##yygtzv7//1HbhENLtIDk////zf@bAgA "Husk – Try It Online")
# Explanation
As proved in lots of places, the answer for inputs `a` and `b` is `ab-a-b = (a-1)(b-1)-1`. `¤` is the 'combine' combinator, so `¤*←` is a function that applies `←` (decrement) to each argument and 'combines' the results by multiplication. Then I decrement the result to get the final output.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 8 bytes
```
1##-+##&
```
[Try it online!](https://tio.run/##RcqxCoAgFIXhVzlwoSUdVKIcCh@hPRokihpqCDfx2c3bUNP/cTinD/t6@nAsPm/osyKSNVGVx/u4whSJEuSAbSKaZ1RwziFGLWCSALflmr9KMRqBjtuWQTOUFdDm0/vWRcamlB8 "Wolfram Language (Mathematica) – Try It Online")
---
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 15 bytes
```
FrobeniusNumber
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zg@9@tKD8pNS@ztNivNDcpteh/QFFmXkm0soKunUJatHJsrIKagr6DQnW1kY6Cca2OAog2B9HGCNrQEMQw1VGwANHmQAEjEMPQUkfByBjOAqs2ArKMLWtr/wMA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 3 bytes
```
<P<
```
[Try it online!](https://tio.run/##yy9OTMpM/W/p5mKvpGBrp6Bk/98mwOa/zv9oBSMdBQXjWC4IwxzEMEZiGBqCGKZAEQsQwxwoYgRkGFrqKBgZwxggxUZAhrFlLAA "05AB1E – Try It Online")
```
<         # decrement both inputs
 P        # product
  <       # decrement
```
[Answer]
# [Python 3](https://docs.python.org/3/), 18 bytes
```
lambda a,b:a*b-a-b
```
[Try it online!](https://tio.run/##K6gsycjPM/6fpmCrEPM/JzE3KSVRIVEnySpRK0k3UTfpf6KOQhJQLjexQCMzr0RHITOvoLREQ1OvuCAnE0hrcnEVFAElNNI0QCo1Nf8bWSoYWwIA "Python 3 – Try It Online")
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~43~~ 13 bytes
```
(*-1)*(*-1)-1
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwX0NL11BTC0zqGv635ipOrFRIUzDSUTBGYpvD2MaobENDGMdUR8ECxjYHShjBOIaWOgpGxig8uAlGQJ6xpfV/AA "Perl 6 – Try It Online")
Turns out there's a much shorter way to calculate the answer.
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 43 bytes
```
->\a,\b{max ^(a*b)∖((a X*^b)X+(^a X*b)):}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwX9cuJlEnJqk6N7FCIU4jUStJ81HHNA2NRIUIrbgkzQhtjTgQM0lT06r2f3FipUKagpGOgrE1F5xtDmMbo7INDWEcUx0FCxjbHChhBOMYWuooGBmj8OAmGAF5xpbW/wE "Perl 6 – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 3 bytes
```
×-+
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT/////B0Xe3/aY/aJjzq7XvUN9XT/1FX86H1xo/aJgJ5wUHOQDLEwzP4v5GlQpqCsSUA "APL (Dyalog Unicode) – Try It Online")
Dyadic train where `a f b` computes `(a×b)-(a+b)`.
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
×_+
```
[Try it online!](https://tio.run/##y0rNyan8///w9Hjt////G1n@N7YEAA "Jelly – Try It Online")
Dyadic link that takes two numbers `a` and `b` as left and right arguments. Works the same as the APL version, just with the symbol `_` instead of `-` to represent subtraction.
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~31~~ 22 bytes
```
f(a,b){return~-a*b-a;}
```
[Try it online!](https://tio.run/##jdDRCoIwFAbge59iGMIWx2COWMPyRaqL6bQGtsL0SuzV1za6bt6cnwMfP5zT5E0vzc3aDkuoyTy04zSYTy63dS7LxW60afpJtcf3qPRzd68SbUb0kNpgMifoNbi1w@k5U4AydUWnysXFpFAAgw67SUj53/HgeNSt62Ohj0X7GFAaIKURuYeDg25GHAdaOOgjIqmAwl8TcoXlPxv9kQAm/Jd8ervYLw "C (clang) – Try It Online")
Saved 9 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
P_S
```
[Try it online!](https://tio.run/##y0rNyan8/z8gPvj///9GljrGlgA "Jelly – Try It Online")
A monadic link taking a pair of integers. Same method as most other answers (product minus sum). 
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 5 bytes
```
-*FQs
```
[Try it online!](https://tio.run/##K6gsyfj/X1fLLbD4/39THQsA "Pyth – Try It Online")
Product minus sum.
```
t*FtM
```
[Try it online!](https://tio.run/##K6gsyfj/v0TLrcT3/39THQsA "Pyth – Try It Online")
a,b -> (a-1)\*(b-1)-1
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 18 bytes
```
f(a,b){a=~-a*b-a;}
```
Noodle9's answer except using `a=` instead of `return`.
[Try it online!](https://tio.run/##jdDRCsIgFAbg@z2FLAYaZ4GTMFnbi1QXTtsSyqLW1Vivbipd527Oz4GPH85R5aCUcz2W0JFJNp9SrrtS1rNbGauub33ev0Zt7ptLmxk7ops0FpMpQ4@nX3ucHwoNqNAn1LQ@jjaHChj02E9C6v@OR8eTblkfi30s2ceA0ggpTcgt7Dz0M@E40MrDEAlJBVThmpgLLP/Z5I8EMBG@FDLY2X0B "C (gcc) – Try It Online")
[Answer]
# Java 8, 13 bytes
```
a->b->a*b-a-b
```
[Try it online.](https://tio.run/##jZAxb4MwEIV3fsWJCYptCVCV0qSMlTp0yth2OBOITByD4iNSVOW3UwdZqpupi/W@u5Pfu@vxjLzfHeZGo7Xwjsp8RwCWkFQDveuKiZQW3WQaUoMRr15s3gy1@/bE/jfkRV1DBy8z8lryGh8kRy7ndeQcx0lq5@iNz4PawdGFSbZ0Umb/8QWY3oIBUGspKViZrkNchVjeY56H/MieQlyxvAg5r1hR3hf@fFhUrKyWwjX6PdaSeekrQ4Ds9kofenux1B7FMJEY3T6kTYJZzOJMZvHzJ8VZJ3Ac9SXB1AuZeoPr/AM)
**Explanation:**
Similar as most other answers, it calculate the product minus the sum:
```
a->b->         // Method with two integer parameters and integer return-type
      a*b      //  Return the two parameters multiplied by each other,
         -a-b  //  after we've also subtracted both parameters from this product
```
[Answer]
# [Whitespace](https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php), 59 bytes
```
[S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input][S N
S _Duplicate_input][S N
S _Duplicate_input][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input][S N
S _Duplicate_input][S T S S T   S N
_Copy_0-based_2nd][T    S S N
_Multiply_top_two][S N
T   _Swap_top_two][T    S S T   _Subtract_top_two][S N
T   _Swap_top_two][T    S S T   _Subtract_top_two][T    N
S T _Print_as_integer_to_STDOUT]
```
Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.  
`[..._some_action]` added as explanation only.
[Try it online](https://tio.run/##K8/ILEktLkhMTv3/X0FBgQsIObk4QQDIQuVwghAXJ1gRJ5QDojiBqv7/N7LkMrYEAA) (with raw spaces, tabs and new-lines only).
**Explanation in pseudo-code:**
```
Integer a = STDIN as integer
Integer b = STDIN as integer
Integer c = a * b
c = c - a - b
Print c as integer to STDOUT
```
Not much golfing involved, except for using the first input as heap-address for the second input, since it's guaranteed to be positive and we push it to stack right away.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~8~~ 7 bytes
```
t*thQte
```
[Try it online!](https://tio.run/##K6gsyfj/v0SrJCOwJPX//2gjSx1jy1gA "Pyth – Try It Online")
Uses the formula (a-1)(b-1) - 1. Takes input as a Python array of 2 integers.
-1 by using implicit appended Q
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 4 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
×-Ux
```
[Try it here](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=1y1VeA&input=WzI5LCAzOV0)
[Answer]
# [Keg](https://github.com/JonoCode9374/Keg), 5 bytes
```
*¿¿+-
```
Simply a port of other answers. Uses latest github interpreter. 
[Answer]
# Excel, 12 bytes
```
=A1*B1-A1-B1
```
Same approach as other answers.
[Answer]
# [JavaScript (V8)](https://v8.dev/), 13 bytes
```
a=>b=>a*b-a-b
```
[Try it online!](https://tio.run/##NY5NDoMgEIX3nmLiSpqhKRCrNsGLGBZopGlDpBHipunZqWCczTcz783PW2/aT@vrE@jWRiOjlv0oe30ZqaZjtHOAMPvgQcIwcBQKYUeTIE4wllhjm9Ag44msQ767M7OPdwiiyxJC7twRWH2sgDxDRVJUYdwK1XkanDleIPAtYI/JLd7Z@Wrds0oCQvkoEUwuhpsiR8IUIcUv/gE "JavaScript (V8) – Try It Online")
Same solution as other answers, I almost didn't post it but for once I found a question without a JS answer, so may as well. In fact this is the exact same as Kevin Cruijssen's answer, replacing Java's lambda `->` with Javascript's `=>`. I've included a very basic testing framework in my TIO link so it does all the test cases. Most invalid inputs still execute.
[Answer]
# Brainf\*ck, 36 bytes
Cell layout: cells 1 and 2 are input, cell 3 is where the final answer is built, cell 4 is auxiliary
```
,->,-<[->[->+>+<<]>>[-<<+>>]<<<]>>-.
```
Or, with words:
```
,-               read a and decrement
>                move to cell 2
,-               read b and decrement
<                move back to a
 [-              while a isn't 0, decrement once and
  >              move to b (to add b to cells 3 and 4)
  [-             decrement b
   >+>+<<        add 1 to cells 3 and 4, go back to b
  ]
  >>             move to cell 4
  [-<<+>>]       copy cell 4 to cell 2 (i.e. put b again in cell 2
 <<<             move back to a
 ]
>>-.             go to cell 3, decrement and output
```
[Try it online](https://copy.sh/brainfuck/?c=LC0-LC08Wy0-Wy0-Kz4rPDxdPj5bLTw8Kz4-XTw8PF0-Pi0u) - this is not a link to tio.run. In this site I linked I was able to give input as `\02\05` so that I could try smaller test cases, and I also get a "memory dump" to check the weird characters that were printed actually correspond to the answer.
Here, have a [tio.run](https://tio.run/##SypKzMxLK03O/v9fR9dOR9cmWtcOiLTttG1sYu2ATBsbbTu7WBswT1fv/38A) link as well.
[Answer]
# AWK, 14 bytes
```
$0=$1*$2-$1-$2
```
[Try it online!](https://tio.run/##HYuxDYAwEMT6m@KKr5AicfcKIQXDUDMA4z8RhV3Z9/tUxX6FtnALtXCVmTAH8kdC54lBGZp0/h7wZE5oNQfVV2i0dXw "AWK – Try It Online")
Assumes input in the form of `x y`.
[Answer]
# [R](https://www.r-project.org/), 11 7 bytes
```
a*b-a-b
```
Where `a` and `b` are the 2 numbers.
Thanks to Jo King for pointing out my error.
]