Agilent Technologies Interview Question

althrithm is hard to check