Forgot to include the comment for Problem 8.
Solved Problem 9.

Quite straightforward with a for loop.