Say you have a number, x
now you multiply x by the amount of digits it has, d
x * d = y
now, say y is, for example, 871416
y = 871416
now assume we forgot what x and d were, although we know that d was the amount of digits that x has. How do we get x back?
This is a question I have for decrypting my own encryption, and it's been stumping me for a while..
now you multiply x by the amount of digits it has, d
x * d = y
now, say y is, for example, 871416
y = 871416
now assume we forgot what x and d were, although we know that d was the amount of digits that x has. How do we get x back?
This is a question I have for decrypting my own encryption, and it's been stumping me for a while..
-
I'm going to assume that we are working with positive integers only.
We need 871416 divided by d to have d digits, and we need 871416 to be
divisible by d. Clearly d <= 6, so try d = 6 first to get 871416 / 6 = 145236,
which does have d = 6 digits, so x = 145236.
Edit: Note that if y has 6 digits and y >= 600000 then d = 6 and so y would
then have to be divisible by 6. If y has 6 digits and y < 500000 then d = 5
and so y would then have to be divisible by 5. For 500000 <= y < 600000
there is no possible value for d, since if d were 6 then x would only have
5 digits, and if d were 5 then x would have 6 digits.
We need 871416 divided by d to have d digits, and we need 871416 to be
divisible by d. Clearly d <= 6, so try d = 6 first to get 871416 / 6 = 145236,
which does have d = 6 digits, so x = 145236.
Edit: Note that if y has 6 digits and y >= 600000 then d = 6 and so y would
then have to be divisible by 6. If y has 6 digits and y < 500000 then d = 5
and so y would then have to be divisible by 5. For 500000 <= y < 600000
there is no possible value for d, since if d were 6 then x would only have
5 digits, and if d were 5 then x would have 6 digits.
-
I'd say, start with the square root of y. This number is the center (average? not a native english speaker) value of a collection of values for x and d, and we can be sure the nearest integer has the number of digits you are looking for. Work your way out from the nearest integer (above or below, doesn't really matter) using the formula y / x = d. So, in your example, the square root of 871416 is 933,496652. The nearest integer below is 933.
d = 871416 / 933 = 933,993569, which isn't an integer.
d = 871416 / 932 = 934,995708, which isn't an integer.
If you have something to plot this in a table, it should be relatively easy to find which d is an integer when x is an integer.
d = 871416 / 933 = 933,993569, which isn't an integer.
d = 871416 / 932 = 934,995708, which isn't an integer.
If you have something to plot this in a table, it should be relatively easy to find which d is an integer when x is an integer.