Specific number, all the zeros has to be changed in a 1

282 Views Asked by At

Let's say I have a number that can be written as:

$$p:=10^x+n\tag1$$

Where $x$ and $n$ are both positive natural numbers, we know that $10^x>n$ and the number $n$ does not contain the digit zero.

How can I turn all the zeros that turn up in the number $p$ into a $1$? How can I write that mathematically?


So for example:

$10^5+12=100000+12=100012\tag2$

So we need to add $11100$, in order to get:

$10^5+12+11100=111112\tag3$

How to write $11100$ in terms of $x$ and $n$?

1

There are 1 best solutions below

0
On

Try something like adding $\dfrac{10^x-10^{1+\lfloor\log_{10}(n)\rfloor}}{9}$

so with your example of $10^5+12$, you would be adding $\frac{10^5-10^{1+\lfloor\log_{10}(12)\rfloor}}{9} = \frac{10^5-10^{2}}{9} = \frac{99900}{9}=11100$