Domanda di colloquio di Google

mathematical question. it was implementation based