Completed Problem 44.

I did a brute force method that works well. Originally I thought there
would be a better, more elegant mathematical solution. However based on
the solutions forum online it appears this is indeed the best and only
way!