doit for more sets using iteration and recursion