Capgemini Interview Question

Basic logical thinking question along with some basic coding question