Pergunta de entrevista da empresa Cognizant

Provide solution through code for even and odd