Here's a little function to take an integer and write it out in words (e.g. input = 34, output = "thirty-four") -- see attached file. This is also another example of recursion. This one's a little harder to convert to iterative since it calls itself at multiple points (and there's less incentive to because the deepest level of recursion it can reach is fairly shallow -- 2 levels). Exercise for the reader: produce an iterative implementation.
It hasn't been optimized for performance either.
Andre Guirard | 14 April 2008 08:34:13 AM ET | Home, Plymouth, MN, USA | Comments (2)

