|
The Maple code uses a recurrence for this function.
Here is a faster algorithm for computing members of this sequence. Input: a positive integer, n
Step 1. Write n in base 4. This yields a string of digits. Each digit is 0, 1, 2 or 3.
Step 2. Make a pass through the string and replace every occurrence of "12" with "6". Now the string is a string of 0's, 1's, 2s, 3s and 6s.
Step 3. Make a pass through the string and replace every occurrence of "21" by "9". Now the string is a string of 0's, 1's, 2s 3s, 6s and 9s.
Step 4. Add the digits of the string. Call this sum S.
Step 5. Compute the product of f(d) over all digits d of the string, where f(0)=1 and f(d)= A099732(d) for d>0. As a table, these values are f(0)=1, f(1)=1, f(2)=2, f(3)=6, f(6)=72 and f(9)=1296. Call this product P.
Step 6. A099732(n)= P * 24^((n-S)/3).
Examples. n=412089:
Step 1. n = 1210212321 in base 4. Step 2. The new string is 61062321. Step 3. The new string is 6106239. Step 4. S = 6+1+0+6+2+3+9= 27. Step 5. P = 72*1*1*72*2*6*1296=80621568. Step 6. A099732(412089)=80621568 * 24^((412089-27)/3) = 80621568 * 24^(412062/3) = 80621568 * 24^137354.
n=25: Step 1. n=121 in base 4. Step 2. The new string is 61. Step 3. The new string is still 61, since there are no "21"s in 61. Step 4. S= 6+1 =7. Step 5. P= 72*1 = 72. Step 6. A099732(25) = 72 * 24^((25-7)/3) = 72 * 24^6.
n=37: Step 1. n=211 in base 4. Step 2. The new string is still 211, since there are no "12"s in "211". Step 3. The new string is 91. Step 4. S= 9+1 = 10. Step 5. P= 1296*1 = 1296. Step 6. A0099732(37) = 1296 * 24^((37-10)/3) = 1296 * 24^9.
It is important that Step 2 be done before Step 3; indeed, proving that doing any of Step 3 before all of Step 2 is accomplished cannot result in a larger value (though it can result in a smaller value, or the same value if there are no "12"-"21" conflicts) is part of the proof of the correctness of this algorithm.
|