DTCC interview question

Math pattern solving and debugging code