If we start with a number like 1234 and produce the following sum 1234 + 123 + 12 + 1 = 1370.
If we are given the 1370 can I retrieve the 1234? A similar question was migrated over to the Math.SE because the OP did not in any way relate it to MMa. The math given over there is in no way too tough for anyone over here but the solution will still require MMA for anything more than a trivial problem. I wish to do it using MMa. This is what I did:
Suppose we have the non trivial problem of reconstructing the original number from 308460277.
Basically, I just used the structure of the FindInstance command as a template and used MMa commands to fill in the various fields.
n = 9; (*digit length of the number*)
m = 308460277;
var = Table[Subscript[a, k], {k, n, 1, -1}];
f = Sum[1/9 (-1 + 10^k) Subscript[a, k], {k, 1, n}] == m;
s = FindInstance[Append[{f, 10 > Subscript[a, 1] > 0},
Table[10 > Subscript[a, k] >= 0, {k, 2, n}]] // Flatten, var,Integers];
var /. s
(*{{2, 7, 7, 6, 1, 4, 2, 5, 3}}*)
So the starting number was 277614253
To check:
277614253 + 27761425 + 2776142 + 277614 + 27761 + 2776 + 277 + 27 + 2 = 308460277
This is pretty fast and can do 98766665555567902460 instantaneously.
What is the right way to do this?
Addenda: My solution gags on m = 137174210013717421001371742085. I was worried about FindInstance being able to do larger ones, that is the reason I posted for a better way.