Why can't you use loops? I suppose you could use recursion here.