User:Ling Kah Jai/Transposable integer

The digits of some specific integers permute or shift cyclically when they are multiplied by a number n. Examples are:


 * 142857 &times; 3 = 428571 (shifts cyclically one place left)
 * 142857 &times; 5 = 714285 (shifts cyclically one place right)
 * 128205 &times; 4 = 512820 (shifts cyclically one place right)
 * 076923 &times; 9 = 692307 (shifts cyclically two places left)

These specific integers can be but are not always cyclic numbers. The characterization of such numbers can be done using repeating decimals (and thus the related fractions), or directly.

General
If an integer does not possess factors of 2 or 5, its reciprocal is a repeating decimal without any non-recurring digits. E.g. $1/143$ = 0. 006993 006993 006993 ...

While the expression of a single series with vinculum on top is adequate, the intention of the above expression is to show that the six cyclic permutations of 006993 can be obtained from this repeating decimal if we select six consecutive digits from the repeating decimal starting from different digits.

This illustrates that cyclic permutations are somehow related to repeating decimals and the corresponding fractions.

The greatest common divisor (gcd) between any cyclic permutation of an m-digit integer and 10m &minus; 1 is constant. Expressed as a formula,


 * $$\gcd\left(N,10^m-1\right)=\gcd\left(N_c,10^m-1\right),$$

where N is an m-digit integer; and Nc is any cyclic permutation of N.

For example, gcd(091575, 999999) = gcd(32×52×11×37, 33×7×11×13×37) = 3663                       = gcd(915750, 999999) = gcd(157509, 999999) = gcd(575091, 999999) = gcd(750915, 999999) = gcd(509157, 999999)

If N is an m-digit integer, the number Nc, obtained by rotating N to the left, can be obtained from:


 * $$N_c = 10 N - d\left(10^m-1\right), \, $$

where d is the first digit of N.

This explains the above common gcd and the phenomenon is true in any base if 10m &minus; 1 is replaced by bm &minus; 1, where b is the base and m is the number of digits.

The cyclic permutations are thus related to repeating decimals, the corresponding fractions, and divisors of 10m&minus;1. For examples the related fractions to the above cyclic permutations are thus: Reduced to their lowest term, they are:
 * $091575/999999$, $915750/999999$, $157509/999999$, $575091/999999$, $750915/999999$, and $509157/999999$.
 * $25/273$, $250/273$, $43/273$, $157/273$, $205/273$, and $139/273$.

That is, these fractions when expressed in lowest terms, have the same denominator. This is true for cyclic permutations of any integer.

Integral multiplier
An integral multiplier refers to the multiplier n being an integer:
 * 1) An integer X shift right cyclically by k positions when it is multiplied by an integer n. X is then the repeating digits of $1/F$, whereby F is F0 = n 10k − 1 (F0 is coprime to 10), or a factor of F0; excluding all values which are not more than n.
 * 2) An integer X shift left cyclically by k positions when it is multiplied by an integer n. X is then the repeating digits of $1/F$, whereby F is F0 = 10k - n, or a factor of F0; excluding all values which are not more than n and which are not coprime to 10.

It is necessary for F to be coprime to 10 in order that $1/F$ is a repeating decimal without any preceding non-repeating digits (see multiple sections of Repeating decimal). If there are digits not in a period, then there is no corresponding solution.

For these two cases, multiples of X, i.e. (j X) are also solutions provided that the integer i satisfies the condition $n j/F$ < 1. Most often it is convenient to choose the smallest F that fits the above. The solutions can be expressed by the formula:
 * $$X = j \frac {10^p-1}{F}$$
 * where p is a period length of $1/F$; and F is a factor of F0 coprime to 10.
 * E.g, F0 = 1260 = 22 &times; 32 &times; 5 &times; 7. The factors excluding 2 and 5 recompose to F = 32 &times; 7 = 63. Alternatively, strike off all the ending zeros from 1260 to become 126, then divide it by 2 (or 5) iteratively until the quotient is no more divisible by 2 (or 5). The result is also F = 63.

To exclude integers that begin with zeros from the solutions, select an integer j such that $j/F$ > $1/10$, i.e. j > $F/10$.

There is no solution when n > F.

Fractional multiplier
An integer X shift left cyclically by k positions when it is multiplied by a fraction $n/s$. X is then the repeating digits of $s/F$, whereby F is F0 = s 10k - n, or a factor of F0; and F must be coprime to 10.

For this third case, multiples of X, i.e. (j X) are again solutions but the condition to be satisfied for integer j is that $n j/F$ < 1. Again it is convenient to choose the smallest F that fits the above.

The solutions can be expressed by the formula:
 * $$X = j s \frac {10^p-1}{F}$$
 * where p is defined likewise; and F is made coprime to 10 by the same process as before.

To exclude integers that begin with zeros from the solutions, select an integer j such that $j s/F$ > $1/10$, i.e. j > $F/10s$.

Again if $j s/F$ > 1, there is no solution.

Direct representation
The direct algebra approach to the above cases of integral multiplier lead to the following formula:
 * 1) $$X=D \frac {10^m-1}{n10^k-1},$$
 * where m is the number of digits of X, and D, the k-digit number shifted from the low end of X to the high end of n X, satisfies D < 10k.
 * If the numbers are not to have leading zeros, then n 10k &minus; 1 ≤ D.
 * 1) $$X = D \frac {10^m-1}{10^k-n},$$
 * where m is the number of digits of X, and D, the k-digit number shifted from the high end of X to the low end of n X, satisfies:
 * $$D<\frac {10^k} n - 1,$$
 * and the 10-part (the product of the terms corresponding to the primes 2 and 5 of the factorization) of 10k &minus; n divides D.
 * The 10-part of an integer t is often abbreviated $$\operatorname{gcd}\left(10^\infty,t\right).$$
 * If the numbers are not to have leading zeros, then 10k &minus; 1 ≤ D.

Cyclic permutation by multiplication
A long division of 1 by 7 gives:

0.142857...     7 ) 1.000000          .7            3           28             2            14              6             56               4              35                5               49                 1

At the last step, 1 reappears as the remainder. The cyclic remainders are {1, 3, 2, 6, 4, 5}. We rewrite the quotients with the corresponding dividend/remainders above them at all the steps: Dividend/Remainders   1 3 2 6 4 5 Quotients             1 4 2 8 5 7

and also note that:


 * $1/7$ = 0.142857...
 * $3/7$ = 0.428571...
 * $2/7$ = 0.285714...
 * $6/7$ = 0.857142...
 * $4/7$ = 0.571428...
 * $5/7$ = 0.714285...

By observing the remainders at each step, we can thus perform a desired cyclic permutation by multiplication. E.g.,
 * The integer 142857, corresponding to remainder 1, permutes to 428571 when multiplied by 3, the corresponding remainder of the latter.
 * The integer 142857, corresponding to remainder 1, permutes to 857142 when multiplied by 6, the corresponding remainder of the latter.
 * The integer 857142, corresponding to remainder 6, permutes to 571428 when multiplied by $5/6$; i.e. divided by 6 and multiplied by 5, the corresponding remainder of the latter.

In this manner, cyclical left or right shift of any number of positions can be performed.

Less importantly, this technique can be applied to any integer to shift cyclically right or left by any given number of places for the following reason:
 * Every repeating decimal can be expressed as a rational number (fraction).
 * Every integer, when added with a decimal point in front and concatenated with itself infinite times, can be converted to a fraction, e.g. we can transform 123456 in this manner to 0.123456123456..., which can thus be converted to fraction $123456/999999$. This fraction can be further simplified but it will not be done here.
 * To permute the integer 123456 to 234561, all one needs to do is to multiply 123456 by $234561/123456$. This looks like cheating but if $234561/123456$ is a whole number (in this case it is not), the mission is completed.

Proof of formula for cyclical right shift operation
An integer X shift cyclically right by k positions when it is multiplied by an integer n. Prove its formula.

Proof

First recognize that X is the repeating digits of a repeating decimal, which always possesses cyclic behavior in multiplication. The integer X and its multiple n X then will have the following relationship:


 * 1) The integer X is the repeating digits of the fraction $1/F$, say dpdp-1...d3d2d1, where dp, dp-1, ..., d3, d2 and d1 each represents a digit and p is the number of digits.
 * 2) The multiple n X is thus the repeating digits of the fraction $n/F$, say dkdk-1...d3d2d1dpdp-1...dk+2dk+1, representing the results after right cyclical shift of k positions.
 * 3) F must be coprime to 10 so that when $1/F$ is expressed in decimal there is no preceding non-repeating digits otherwise the repeating decimal does not possess cyclic behavior in multiplication.
 * 4) If the first remainder is taken to be n then 1 shall be the (k + 1)th remainder in the long division for $n/F$ in order for this cyclic permutation to take place.
 * 5) In order that n &times; 10k = 1 (mod F) then F shall be either F0 = (n &times; 10k - 1), or a factor of F0; but excluding any values not more than n and any value having a nontrivial common factor with 10, as deduced above.

This completes the proof.

Proof of formula for cyclical left shift operation
An integer X shift cyclically left by k positions when it is multiplied by an integer n. Prove its formula.

Proof

First recognize that X is the repeating digits of a repeating decimal, which always possesses a cyclic behavior in multiplication. The integer X and its multiple n X then will have the following relationship:


 * 1) The integer X is the repeating digits of the fraction $1/F$, say dpdp-1...d3d2d1.
 * 2) The multiple n X is thus the the repeating digits of the fraction $n/F$, say dp-kdp-k-1...d3d2d1dpdp-1...dp-k+1, which represents the results after left cyclical shift of k positions.
 * 3) F must be coprime to 10 so that $1/F$ has no preceding non-repeating digits otherwise the repeating decimal does not possess cyclic behavior in multiplication.
 * 4) If the first remainder is taken to be 1 then n shall be the (k + 1)th remainder in the long division for $1/F$ in order for this cyclic permutation to take place.
 * 5) In order that 1 &times; 10k = n (mode F) then F shall be either F0 = (10k -n), or a factor of F0; but excluding any value not more than n, and any value having a nontrivial common factor with 10, as deduced above.

This completes the proof. The proof for non-integral multiplier such as $n/s$ can be derived in a similar way and is not documented here.

Shifting an integer cyclically
The permutations can be:


 * Shifting right cyclically by single position (parasitic numbers);
 * Shifting right cyclically by double positions;
 * Shifting right cyclically by any number of positions;
 * Shifting left cyclically by single position;
 * Shifting left cyclically by double positions; and
 * Shifting left cyclically by any number of positions

Parasitic numbers
When a parasitic number is multiplied by n, not only it exhibits the cyclic behavior but the permutation is such that the last digit of the parasitic number now becomes the first digit of the multiple. For example, 102564 x 4 = 410256. Note that 102564 is the repeating digits of $4/39$ and 410256 the repeating digits of $16/39$.

Shifting right cyclically by double positions
An integer X shift right cyclically by double positions when it is multiplied by an integer n. X is then the repeating digits of $1/F$, whereby $F$ = n &times; 102 - 1; or a factor of it; but excluding values for which $1/F$ has a period length dividing 2 (or, equivalently, less than 3); and $F$ must be coprime to 10.

Most often it is convenient to choose the smallest $F$ that fits the above.

Summary of results
The following multiplication moves the last two digits of each original integer to the first two digits and shift every other digits to the right:

Note that:
 * 299 = 13 x 23, and the period of $1/199$ is accurately determined by the formula, LCM(6, 22) = 66, according to Repeating decimal.
 * 399 = 3 x 7 x 19, and the period of $2/199$ is accurately determined by the formula, LCM(1, 6, 18) = 18.

There are many other possibilities.

Shifting left cyclically by single position
Problem: An integer X shift left cyclically by single position when it is multiplied by 3. Find X.

Solution: First recognize that X is the repeating digits of a repeating decimal, which always possesses some interesting cyclic behavior in multiplications. The integer X and its multiple then will have the following relationship:


 * The integer X is the repeating digits of the fraction $2/199$, say ab***.
 * The multiple is thus the repeating digits of the fraction $3/199$, say b***a.
 * In order for this cyclic permutation to take place, then 3 shall be the next remainder in the long division for $99/199$. Thus $F$ shall be 7 as 1 &times; 10 ÷ 7 gives remainder 3.

This yields the results that:


 * X = the repeating digits of $1/299$
 * =142857, and
 * the multiple = 142857 &times; 3 = 428571, the repeating digits of $3/299$

The other solution is represented by $2/299$ x 3 = $3/299$:
 * 285714 x 3 = 857142

There are no other solutions because:
 * Integer n must be the subsequent remainder in a long division of a fraction $99/299$. Given that n = 10 - F, and F is coprime to 10 in order for $1/13$ to be a repeating decimal, then n shall be less than 10.
 * For n = 2, F must be 10 - 2 = 8. However $3/13$ does not generate a repeating decimal, similarly for n = 5.
 * For n = 7, F must be 10 - 7 = 3. However 7 > 3 and $2/13$ = 2.333 > 1 and does not fit the purpose.
 * Similarly there is no solution for any other integer of n less than 10 except n = 3.

However, if the multiplier is not restricted to be an integer (though ugly), there are many other solutions from this method. E.g., if an integer X shift right cyclically by single position when it is multiplied by $3/13$, then 3 shall be the next remainder after 2 in a long division of a fraction $4/13$. This deduces that F = 2 x 10 - 3 = 17, giving X as the repeating digits of $1/23$, i.e. 1176470588235294, and its multiple is 1764705882352941.

The following summarizes some of the results found in this manner:

Shifting left cyclically by double positions
An integer X shift left cyclically by double positions when it is multiplied by an integer n. X is then the repeating digits of $3/23$, whereby $F$ is $R$ = 102 - n, or a factor of $R$; excluding values of $F$ for which $2/23$ has a period length dividing 2 (or, equivalently, less than 3); and F must be coprime to 10.

Most often it is convenient to choose the smallest $F$ that fits the above.

Summary of results
The following summarizes some of the results obtained in this manner, where the white spaces between the digits divide the digits into 10-digit groups:

Adding or subtracting cyclic permutations by repdigit
Subtract 1-repdigit from (or add 1-repdigit to) each element of a set of cyclic permutations, and if necessary add (or subtract) 9-repdigit in order for all the results to be within the positive range between 0 and 9-repdigit. The operation produces a second set of cyclic permutations.

Replace 1-repdigit by n-repdigit, where n is a integer between 2 and 9, different sets of cyclic permutations are produced.

The consequence (operation on a set of cyclic permutations results in another set of cyclic operations) is obvious if we perform the same operation on their repeating decimal equivalents, not fractions, of a few cyclic permutations and compare the results. For example, compare the following two additions (reduce by 1 if the result is bigger than 1): 0.142857 142857 142857...                0.428571 428571 428571... + 0.666666666666666666...      with     + 0.666666666666666666....

Adding or subtracting two sets of cyclic permutations
Arrange two sets of cyclic permutations in the proper cyclic order (each set does not need to start from the smallest number). Then add (or subtract) every element of the second set to (from) the first set, and if necessary subtract (or add) 9-repdigit in order for all the results to be within the positive range between 0 and 9-repdigit. The operation produces a third set of cyclic permutations.

Again such consequence is obvious if we perform the same operation on their repeating decimal equivalents, not fractions, of a few cyclic permutations and compare the results. For example, compare the following two additions (reduce by 1 if the result is bigger than 1): 0.076923 076923 076923...                0.769230 769230 769230... + 0.142857142857142857...      with     + 0.428571428571428571....

From this perspective, the previous feature is also covered here as the set of cyclic permutations for 111111 is no other than {111111, 111111, 111111, 111111, 111111, 111111}.

The table below shows the above operation in terms of equivalent fractions. Subtract the result by 1 if it is greater than 1.

The rule, in the form of modular mathematics, can be deduced from these fraction equivalents:


 * Given:
 * Two integers F1 and F2 are coprime to each other;
 * The operation &times;10 (mod F1) on an integer R1 generates a closed set of integers {R1, R2, ..., Rn};
 * The operation &times;10 (mod F2) on another integer S1 generates a closed set of integers {S1, S2, ..., Sn}; and
 * The two sets of integers have the same number of elements;
 * T1 = F2 R1 + F1 S1;
 * Then the operation &times;10 (mod F1 F2) on T1 shall generate the closed set of integers {T1, T2, ..., Ti, ..., Tn}, where Ti = F2 Ri + F1 Si