Fairly straightforward way of implementing the code to answer this problem.