That was one of the sample projects/examples in my old C textbook (which I still have). I could look for the code online when I get home if you want.
On the other hand, it shouldn't be too hard to write using a recursive function.
On the other hand, it shouldn't be too hard to write using a recursive function.