Simple Implementation for Problem 16