Update Problem 17 to not use predefined functions