Original version
Program for homework 3.