This question already has an answer here:
- The Coin Problem 5 answers
You are starting up a cryptocurrency exchange website which supports conversion from USD to two currencies, foo-coin and bar-coin. Write a program that takes the exchange rate for each coin to USD as arguments and outputs the maximum value of USD that cannot be completely divided into the two currencies (assuming these crypto-coins can only be purchased as full coins):
e.g. If the two exchange rates are $23 and $18, then 41 dollars could be split into 1 foo-coin and 1 bar-coin, but there is no way to completely split 42 dollars between the two coins. The output of the program for these two values is 373, as that is the largest dollar amount that CANNOT be divided into whole values of foo-coin and bar-coin.
Winner is the program with the fewest characters.
edit: You may assume the GCD of the two rates is 1