Cognizant Interview Question

Basic coding challenge in any of the languages like C, C++, Python.