Siemens interview question

one coding question some puzzles related to mathematics