changed hw1 problem 4 to call recurivelly at the end