Barclays interview question

typical math and programming problems