Google Interview Question

mathematical question. it was implementation based