Google interview question

mathematical question. it was implementation based