Question d’entretien chez Prudential

Solve this coding challenge using any language you prefer.