Solution for problem #13 in go.