problem 5 solved.
Problem 6 solved.
Problem 7 solved with recursion.