Amazon interview question

directly write a program or function to solve a problem (bugs frww)