some exercise using Prolog and recursion