Problem 3 needs to be fixed for large inputs