Goldman Sachs Interview Question

Coding related to maths