I have encountered this type of puzzle, that usually involves apples, several times. It goes as follows:
There is a certain number of apples in a basket. Ava takes a third of the apples. Bob takes a quarter of the apples that are left. Finally, Dennis takes one-sixth of the apples left. In the end, there are 10 leftover apples. How many apples were in the basket?
The answer to the above task is 24.
Given a list of positive integers and an integer representing the apples left in the end, return the number of apples originally in the basket.
- The \$n\$th element of the list represents the \$\frac 1 k\$ share of apples the \$n\$th person took in the apples left over.
- There will always exist one integer solution, but the step calculations might result in rational numbers
- This is code-golf, so the shortest answer wins.
[3, 4, 6], 10 -> 24 , 14 -> 28 , 30 -> 36 [4, 3], 20 -> 40 [5, 8, 7], 9 -> 15 [2, 9, 4, 8], 7 -> 24