We are not going to do your program for you. You need to either attempt it (at the least) or let us know what specifics in the problem statement you are having so that we may point you in the appropriate direction.
If you have code and are stuck, post it. Else if you are just stuck, which part are you stuck with?
"To iterate is human, to recurse divine." -L. Peter Deutsch