1

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.

scrutari
  • 279

1 Answers1

1

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}$$

  • If a loops is unavoidable, is it possible to have it in form of a recurrence formula? – scrutari Oct 19 '19 at 10:17
  • @scrutari Yeah, you could say that $f(1234)=f(123)\cdot100+4$. I suspect that would not be "elegant" if that definition involves being faster or prettier than string manipulation, but there's nothing stopping you from testing it out! –  Oct 19 '19 at 10:24