Solution to first programming exercise chapter 1.