add commas to Numbers without String manipulation This challenge consist in adding commas to numbers every 3 spaces like:

123456789 =&gt; 123,456,789


Specifications:


The possible inputs will be 1,000 &lt;= input &lt;= 100,000,000
You can ONLY use Mathematical Operators
(*) You can NOT do string, array, index or character manipulation
You can NOT use any kind of built-in functions that add these commas
The zeros should remain, ex 10000 =&gt; 10,000
You need to print/alert/log the output (so "the output is at x
var" is not allowed)


(*) the only exception is when forming/printing the output (but not in a manner that suggest cheating)

Examples

10100 =&gt; 10,100
120406 =&gt; 120,406
999999999 =&gt; 999,999,999




A basic idea on how to get numbers legally:

n = 123456;
m = roundDown(n / 10);//even if ends with .9
d = n - m;//we get the last number
You weren't very specific on the output format...

Haskell, 56

reverse.takeWhile(&gt;0).map(`mod`1000).iterate(`div`1000)


example:

GHCi&gt; reverse.takeWhile(&gt;0).map(`mod`1000).iterate(`div`1000)$93842390862398
[93,842,390,862,398]