Solution for ex 1-4.