Kitamasa algorithm 2026-10-20
The Kitamasa algorithm evaluates a term of an order- linear recurrence by reducing powers of modulo its characteristic polynomial of a linear recurrence. If the recurrence relation is , reduce modulo by exponentiation by squaring; the resulting coefficients give as a linear combination of . Straightforward polynomial multiplication gives arithmetic operations.
There is no forbidden pair in a sequence of length zero or one, so . For , divide acceptable sequences into two disjoint cases. If the first digit differs from , its probability is , and the remaining independent digits must avoid the pair. If the first digit is , the next must differ from , which has combined probability , and the remaining digits must avoid the pair. The boundary between this prefix and the remaining digits cannot create a forbidden pair, because the prefix ends in a digit other than . ConsequentlyThe characteristic polynomial of a linear recurrence is , with distinct rootsWriting , the initial conditions give and . ThereforeFor example, , since only one of the nine equally likely pairs is forbidden. This is the case with success probability of the avoidance recurrence for two consecutive successes.