Cognizant interview question

Write the code for Fan to work.