Code for problem #19.