Number that when multiplied by another number moves its last digit to its front
In mathematics, an n-parasitic number (in base 10) is a positive natural number which, when multiplied by n, results in movement of the last digit of its decimal representation to its front. Here n is itself a single-digit positive natural number. In other words, the decimal representation undergoes a right circular shift by one place.
For example:
4 × 128205 = 512820, so 128205 is 4-parasitic.
Most mathematicians do not allow leading zeros to be used, and that is a commonly followed convention.
So even though 4 × 25641 = 102564, the number 25641 is not 4-parasitic.
Derivation
An n-parasitic number can be derived by starting with a digit k (which should be equal to n or greater) in the rightmost (units) place, and working up one digit at a time.
For example, for n = 4 and k = 7
4 × 7 = 28
4 × 87 = 348
4 × 487 = 1948
4 × 9487 = 37948
4 × 79487 = 317948
4 × 179487 = 717948.
So 179487 is a 4-parasitic number with units digit 7. Others are 179487179487, 179487179487179487, etc.
In general, an n-parasitic number can be found as follows. Pick a one digit integer k such that k ≥ n, and take the period of the repeating decimalk/(10n−1).
This will be
where m is the length of the period; i.e. the multiplicative order of 10 modulo(10n − 1).
For another example, if n = 2, then 10n − 1 = 19 and the repeating decimal for 1/19 is
So that for 2/19 is double that:
The length m of this period is 18, the same as the order of 10 modulo 19, so 2 × (1018 − 1)/19 = 105263157894736842.
105263157894736842 × 2 = 210526315789473684, which is the result of moving the last digit of 105263157894736842 to the front.
Additional information
The step-by-step derivation algorithm depicted above is a great core technique but will not find all n-parasitic numbers. It will get stuck in an infinite loop when the derived number equals the derivation source. An example of this occurs when n = 5 and k = 5. The 42-digit n-parasitic number to be derived is 102040816326530612244897959183673469387755. Check the steps in Table One below. The algorithm begins building from right to left until it reaches step 15—then the infinite loop occurs. Lines 16 and 17 are pictured to show that nothing changes. There is a fix for this problem, and when applied, the algorithm will not only find all n-parasitic numbers in base ten, it will find them in base 8 and base 16 as well. Look at line 15 in Table Two. The fix, when this condition is identified and the n-parasitic number has not been found, is simply to not shift the product from the multiplication, but use it as is, and append n (in this case 5) to the end. After 42 steps, the proper parasitic number will be found.
There is one more condition to be aware of when working with this algorithm, leading zeros must not be lost. When the shift number is created it may contain a leading zero which is positionally important and must be carried into and through the next step. Calculators and computer math methods will remove leading zeros. Look at Table Three below displaying the derivation steps for n = 4 and k = 4. The Shift number created in step 4, 02564, has a leading zero which is fed into step 5 creating a leading zero product. The resulting Shift is fed into Step 6 which displays a product proving the 4-parasitic number ending in 4 is 102564.
Table Three
1. 4 × 4 = 16 − Shift = 64
2. 4 × 64 = 256 − Shift = 564
3. 4 × 564 = 2256 − Shift = 2564
4. 4 × 2564 = 10256 − Shift = 02564
5. 4 × 02564 = 010256 − Shift = 102564
6. 4 × 102564 = 410256 − Shift = 102564
Smallest n-parasitic numbers
The smallest n-parasitic numbers are also known as Dyson numbers, after a puzzle concerning these numbers posed by Freeman Dyson.[1][2][3] They are: (leading zeros are not allowed) (sequence A092697 in the OEIS)
In general, if we relax the rules to allow a leading zero, then there are 9 n-parasitic numbers for each n. Otherwise only if k ≥ n then the numbers do not start with zero and hence fit the actual definition.
Other n-parasitic integers can be built by concatenation. For example, since 179487 is a 4-parasitic number, so are 179487179487, 179487179487179487 etc.
Other bases
In duodecimal system, the smallest n-parasitic numbers are: (using inverted two and three for ten and eleven, respectively) (leading zeros are not allowed)
In strict definition, least number m beginning with 1 such that the quotient m/n is obtained merely by shifting the leftmost digit 1 of m to the right end are
1, 105263157894736842, 1034482758620689655172413793, 102564, 102040816326530612244897959183673469387755, 1016949152542372881355932203389830508474576271186440677966, 1014492753623188405797, 1012658227848, 10112359550561797752808988764044943820224719, 10, 100917431192660550458715596330275229357798165137614678899082568807339449541284403669724770642201834862385321, 100840336134453781512605042016806722689075630252, ... (sequence A128857 in the OEIS)
They are the period of n/(10n − 1), also the period of the decadic integer -n/(10n − 1).