NTT DATA interview question

To write code for a simple math problem