Here’s a numeric approach. The feedback loop is a little scary in Max land, but will *not* stack overflow with integers. Salt to taste (particularly if you want the digits printed in left-to-right order).
Incidentally, there was another thread recently claiming the rightmost outlet from sel was inutile. Au contraire. This is an idiomatic example of using sel to break a loop by only using the right outlet. Study carefully.