Texas Instruments Interview Question

pseudeocode for the given coding challenges.