Cognizant Interview Question

Provide solution through code for even and odd