Publicis Sapient interview question

Writing a code for some random function .