Just started and got stuck on 1b - got close but found out that I missed the while at the start. Why do I need the while at the start of the solution
every time the logic under while checks newBalance after payment of monthly instalment for month 1 to 12. If while running this, newBalance for any of the step becomes less than zero, ans is arrived. If the piece runs for 12 months for a value of 'minPay' and still the newBalance is not zero, the newBalance has to be calculated for a new 'minpay' (which is minpay +10) for all 12 months again. So every time, after calculating NewBalance, even after calcualting for 12 months is balance is not zero, the process needs to repeat. That's why we need to have a logic 'while balance is more than zero, run the code again for 12 months for a new 'minpay' value.
Join our real-time social learning platform and learn together with your friends!