Duplicate each digit in a whole number with arithmetic operations

31 Views Asked by At

Is it possible to take a whole number $x$ and produce another whole number $y$ which decimal form would have all digits from $x$ duplicated (e.g. $123 \rightarrow 112233$) using solely arithmetic operations?

This question is inspired by programming questions like this one - the idea is to have an elegant solution which avoids using conversion to a string.

1

There are 1 best solutions below

2
On BEST ANSWER

I'm going to say no. The hitch is that $112233=11\cdot10203$, but any function smart enough to do $12\mapsto102$, $123\mapsto10203$, $1234\mapsto1020304$ and so on is going to need a loop in it.

Contrast with making $123123=123\cdot 1001$, which is achievable in a relatively simple function, since $$1001=1+10^{\lfloor\log_{10}123\rfloor+1}$$