Solution to #2-6