Pregunta de entrevista de Jenius Bank

Math style leetcode question, leetcode medium / hard