Prudential Interview Question

Solve this coding challenge using any language you prefer.