Working on problem 5 and a new function!

I have an infinitie loop in problem 5. No idea why.