← all problems

nextBusMinute 🌶️

A bus leaves the stop at minute every, then at 2 every, 3 every, and so on. You get to the stop at minute arrive. If a bus leaves at the very minute you arrive, you just miss it.

Write a method nextBusMinute that takes every (1 or more) and arrive (0 or more) and returns the minute of the first bus that leaves after you arrive. Use a while loop.

For example, nextBusMinute(10, 25) is 30, and nextBusMinute(10, 30) is 40.