Cognizant interview question

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