coin_a and coin_b; both are distinct prime numbers. It never gives change, so you can only pay an amount that is made up exactly of such coins. You have an unlimited supply of each.
Some small amounts cannot be formed this way, but past a certain point every amount can. Return the largest positive integer amount that cannot be paid.coin_a=3, coin_b=5 → 7
The amounts 1, 2, 4 and 7 cannot be paid. Every amount from 8 up can: 8 = 3 + 5, 9 = 3 + 3 + 3, 10 = 5 + 5, and from there you just keep adding 3s.
coin_a=2, coin_b=7 → 5
2s cover every even amount, and odd amounts become payable starting at 7, so only 1, 3 and 5 are out of reach.
coin_a=11, coin_b=13 → 119
coin_a and coin_b are distinct primescoin_a=3, coin_b=5
7
Run checks the first 3 tests in your browser. Submit checks all 71 tests on the server, hidden ones included.