Sunday 13 December 2020

digit problem

Find all natural numbers, for which, if you knock off the first digit, the remaining number is a divisor of the original number.
You can find these numbers here: https://oeis.org/A292683

First of, let us write our number as
y10n+xy*10^n + x with the extra conditions y<10y<10 and x<10nx< 10^n.
xx is obviously the number with the first digit removed, so we have to find all xx, yy and nn such that there exists a natural number zz such that:
zx=y10n+xzx = y*10^n+x

(z1)x=y10n(z-1)x = y*10^n

As the left and right side of the equation have the same prime decomposition, we can find 4 new numbers, a,b,ca,b,c and dd such that:
ab=xcd=z1ac=ybd=10n\begin{aligned} ab&=x\\cd&=z-1\\ac&=y\\bd&=10^n \end{aligned}

The last one: bd=10nbd=10^n can for the same reason be simplified to b=2k5lb=2^k5^l and d=2nk5nld=2^{n-k}5^{n-l}, simplifing everying to:
x=a2k5lz=c2nk5nl+1y=ac\begin{aligned} x&=a2^k5^l\\z&=c2^{n-k}5^{n-l}+1\\y&=ac \end{aligned}
We are uninterested in the value of z, so this mean that our original value is:
ac10n+a2k5lac10^n+a2^k5^l
with the extra conditions of ac<10ac < 10 and n>log10(a2k5l)n > \log_{10}(a2^k5^l)
The second condition can be smoothed by replacing nn by m+log10(a2k5l)m+\lceil{\log_{10}(a2^k5^l)}\rceil
As all numbers are natural numbers anyway. This reduces the expression to

ac10m+log10(a2k5l)+a2k5lac10^{m+\lceil{\log_{10}(a2^k5^l)}\rceil}+a2^k5^l
m,km,k and ll can assume any natural number, aa and cc can assume the following pairs:
(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(2,1),(2,2),(2,3),(2,4),(3,1),(3,2),(3,3),(4,1),(4,2),(5,1),(6,1),(7,1),(8,1) or (9,1).

Each combination generates a unique number, and each number is generated by this formula.