f(x)=⎩⎨⎧110xx+1if x=1if x is divisible by 10otherwise
and define a sequence as follows: x1=x and xn+1=f(xn) for all positive integers n. Let d(x) be the smallest n such that xn=1. (For example, d(100)=3 and d(87)=7.) Let m be the number of positive integers x such that d(x)=20. Find the sum of the distinct prime factors of m.
解析
Solution
Solution 1
We backcount the number of ways. Namely, we start at x20=1, which can only be reached if x19=10, and then we perform 18 operations that either consist of A:(−1) or B:(×10). We represent these operations in a string format, starting with the operation that sends f(x18)=x19 and so forth downwards. There are 29 ways to pick the first 9 operations; however, not all 9 of them may be A:(−1) otherwise we return back to x10=1, contradicting our assumption that 20 was the smallest value of n. Using complementary counting, we see that there are only 29−1 ways.
Since we performed the operation B:(×10) at least once in the first 9 operations, it follows that x10≥20, so that we no longer have to worry about reaching 1 again.
However, we must also account for a sequence of 10 or more A:(−1)s in a row, because that implies that at least one of those numbers was divisible by 10, yet the 10x was never used, contradiction. We must use complementary counting again by determining the number of strings of A,Bs of length 18 such that there are 10As in a row. The first ten are not included since we already accounted for that scenario above, so our string of 10As must be preceded by a B. There are no other restrictions on the remaining seven characters. Letting □ to denote either of the functions, and [k] to indicate that the character appears k times in a row, our bad strings can take the forms:
BA[10]□□□□□□□□BA[10]□□□□□□⋯⋯□□□□□□BA[10]□□□□□□□□BA[10]
There are 27 ways to select the operations for the 7□s, and 8 places to place our BA[10] block. Thus, our answer is 29(29−1)−8⋅27=218−29−8⋅27=29×509, and the answer is 511.
Note: This solution is quick and most similar to the official solution; however, neither this nor the official solution prove that the final results of these inverted operations are all distinct. A more sophisticated argument, such as the one below, is needed to do so.
Solution 2
We approach the problem by recursion. We partition the positive integers into the sets
An,k={x∈Z+:d(x)=n and x≡k(mod10)}.
First, we note that A1,1={1}, so by the disjointness of the An,k's, we know that 1 is not in any of the other sets. Also, we note that A1,k=∅ for k=0,2,3,4,5,6,7,8,9.
We claim that if 2≤k≤9 and n≥2, then ∣An,k∣=∣An−1,k+1∣. To prove this, we show that f (the given function) maps An,k bijectively onto An−1,k+1. If x∈An,k, then x≡k(mod10), and x=1, so f(x)=x+1≡k+1(mod10). Also, f(n)(x)=1, where n is the smallest positive integer for which this is true. Therefore, fn−1(f(x))=1, where n−1 is the smallest integer for which this is true. Thus f(x)∈An−1,k+1. Also, since f(x)=x+1 on this set, we see that f(x)=f(y) implies that x=y. Hence f is an injection. If y∈An−1,k+1, then y−1≡k(mod10), where 2≤k≤9, so we know that f(y−1)=y, and y−1∈An,k. Therefore, f is a surjection, so it must be a bijection. Therefore, if 2≤k≤9 and n≥2, then ∣An,k∣=∣An−1,k+1∣.
We also claim that if k=1, n≥2 and n=11, then ∣An,k∣=∣An−1,k+1∣. The proof is the same as in the previous paragraph, though some additional clarification is needed to prove that f is a surjection. If y∈An−1,k+1, or rather y−1≡k≡1(mod10), then if y=2, we see that y−1=1, and then f(y−1)=1, not y as in the prior argument. However, this does not happen if n=11. It is easy to check that 2∈A10,2. Therefore, the only time that the above argument could fail is if n−1=10 and k+1=2. But in every other case, ∣An,k∣=∣An−1,k+1∣.
Next, we claim that if n≥3, then
∣An,0∣=k=0⋃9An−1,k
If x∈An,0, then f(x)=10x, which is clearly an injective map. Also, f(n)(x)=1, where n is the smallest positive integer for which this is true. Therefore, fn−1(f(x))=1, where n−1 is the smallest integer for which this is true. Thus f(x)∈An−1,k for some k. Conversely, if y∈An−1,k, then f(10y)=y, so d(10y)=n, so 10y∈An,0.
Based on these bijections, if we let An,k=∣An,k∣, then
An,0An,1An,2An,3An,8An,9=k=0∑9An−1,k=An−1,2if n=11=An−1,3=An−1,4⋮=An−1,9=An−1,0.
Let Sn=∑k=09An,k. Then by adding the above equations (valid if n=11), we find that
Sn=2Sn−1−An−1,1.
Now by using the above relations repeatedly, we find
An−1,1=An−2,2=An−3,3=⋯=An−9,9=An−10,0=Sn−11.
The first relation will only be valid if n=12. Therefore, Sn=2Sn−1−Sn−11 for n≥13. For smaller values, it is easy to use the relations to compute that the terms are powers of 2, although we note that A11,1=0 because of the failure of the above argument.
n123456789101112An,1100000000001An,2000000000112An,3000000001124An,4000000011248An,50000001124816An,600000112481632An,7000011248163264An,800011248163264128An,90011248163264128256An,0011248163264128256511Sn112481632641282565111022
After this, we can simply use the recurrence relation for Sn, finding
n1234567891011121314151617181920Sn11212223242526272829−1210−2211−1⋅5212−2⋅6213−4⋅7214−8⋅8215−16⋅9216−32⋅10217−64⋅11218−128⋅12.
Therefore, there are 218−29⋅3 positive integers x with d(x)=20. This factors as 29(29−3)=29(509), where 509 is prime. Thus the answer is 511.