Let be a natural number. We define the perfect digit-to-digit invariant function for base to be the following: where is the number of digits in the number in base and is the value of each digit of the number. As 00 is usually undefined, there are typically two conventions used, one where it is taken to be equal to one, and another where it is taken to be equal to zero. A natural number is a perfect digit-to-digit invariant if it is a fixed point for, which occurs if. For the first convention, is a fixed point for all, and thus is a trivial perfect digit-to-digit invariant for all, and all other perfect digit-to-digit invariants are nontrivial perfect digit-to-digit invariants. For the second convention, both and are trivial perfect digit-to-digit invariants. For example, the number 3435 in base is a perfect digit-to-digit invariant because. For, in the first convention, is simply the number of digits in the base 2 representation, and in the second convention, is simply the digit sum. A natural number is a sociable digit-to-digit invariant if it is a periodic point for, where for a positive integer, and forms a cycle of period. A perfect digit-to-digit invariant is a sociable digit-to-digit invariant with, and a amicable digit-to-digit invariant is a sociable digit-to-digit invariant with. All natural numbers are preperiodic points for, regardless of the base. This is because all natural numbers of base with digits satisfy. However, when, then, so any will satisfy until. There are a finite number of natural numbers less than, so the number is guaranteed to reach a periodic point or a fixed point less than, making it a preperiodic point. This means also that there are a finite number of perfect digit-to-digit invariant and cycles for any given base. The number of iterations needed for to reach a fixed point is the -factorion function's persistence of, and undefined if it never reaches a fixed point.
Perfect digit-to-digit invariants and cycles of for specific
def pddif -> int: total = 0 while x > 0: total = total + pow x = x // b return total def pddif_cycle -> List: seen = while x not in seen: seen.append x = pddif cycle = while x not in cycle: cycle.append x = pddif return cycle
Convention
def pddif -> int: total = 0 while x > 0: if x % b > 0: total = total + pow x = x // b return total def pddif_cycle -> List: seen = while x not in seen: seen.append x = pddif cycle = while x not in cycle: cycle.append x = pddif return cycle