0👍
It seems to me that you haven’t modeled your problem very clearly. You ought to have a structure that keeps track of remaining intervals, active seconds-this-interval, and rest seconds-this-interval. Each second, you decrement active if it’s > 0, else decrement rest if it’s > 0, else if intervals > 0, decrement intervals and reset active and rest.
Source:stackexchange.com