, 1 i.
That is, you start counting from 1 to n-1, which means that you loop one less time than you planned. So, if numCustomers is 4, the result of the loop:
i starts at | 0 | 1 | 2 | 3 | 4 |
---------------------------------
i loop... | 4 | 3 | 2 | 1 | 0 |
So, I do not get enough time if I start with 1. You will need to make one of two changes. Change i to start at 0, or change the comparison as <=. Will work.
And don’t worry, this is a common mistake!
(Quantic credit to answer the comment!)
source
share