Adds problem #5 - working but too slow