Completed Problem 5 (Brute Force)