Integrated common function that was written each problem.