Perfect digit-to-digit invariant

In number theory, a perfect digit-to-digit invariant (PDDI; also known as a Munchausen number) is a natural number in a given number base formula_1 that is equal to the sum of its digits each raised to the power of itself. For example, in base 3 (ternary) there are three: 1, 12, and 22. The term "Munchausen number" was coined by Dutch mathematician and software engineer Daan van Berkel in 2009, as this evokes the story of Baron Munchausen raising himself up by his own ponytail because each digit is raised to the power of itself.
Definition.
Let formula_2 be a natural number. We define the perfect digit-to-digit invariant function for base formula_3 formula_4 to be the following:
where formula_6 is the number of digits in the number in base formula_1 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 formula_2 is a perfect digit-to-digit invariant if it is a fixed point for formula_10, which occurs if formula_11. For the first convention, formula_12 is a fixed point for all formula_1, and thus is a trivial perfect digit-to-digit invariant for all formula_1, and all other perfect digit-to-digit invariants are nontrivial perfect digit-to-digit invariants. For the second convention, both formula_15 and formula_12 are trivial perfect digit-to-digit invariants.
For example, the number 3435 in base formula_17 is a perfect digit-to-digit invariant because formula_18.
For formula_19, in the first convention formula_20, formula_21 is simply the number of digits formula_22 in the base 2 representation, and in the second convention formula_23, formula_21 is simply the digit sum. 
A natural number formula_2 is a sociable digit-to-digit invariant if it is a periodic point for formula_26, where formula_27 for a positive integer formula_22, and forms a cycle of period formula_22. A perfect digit-to-digit invariant is a sociable digit-to-digit invariant with formula_30, and a amicable digit-to-digit invariant is a sociable digit-to-digit invariant with formula_31.
All natural numbers formula_2 are preperiodic points for formula_10, regardless of the base. This is because all natural numbers of base formula_1 with formula_22 digits satisfy formula_36. However, when formula_37, then formula_38, so any formula_2 will satisfy formula_40 until formula_41. There are a finite number of natural numbers less than formula_42, so the number is guaranteed to reach a periodic point or a fixed point less than formula_42, 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 formula_1.
The number of iterations formula_45 needed for formula_46 to reach a fixed point is the formula_1-factorion function's persistence of formula_2, and undefined if it never reaches a fixed point.
Perfect digit-to-digit invariants and cycles of formula_10 for specific formula_1.
All numbers are represented in base formula_1. 
Programming examples.
Python.
The following program in Python determines whether an integer number is a Munchausen Number / Perfect Digit to Digit Invariant or not, following the convention formula_20.
num = int(input("Enter number:"))
temp = num
s = 0.0
while num > 0:
 digit = num % 10
 num //= 10
 s+= pow(digit,digit)
if s == temp:
 print("Munchausen Number")
else:
 print("Not Munchausen Number")
The examples below implements the perfect digit-to-digit invariant function described in the definition above to search for perfect digit-to-digit invariants and cycles in Python for the two conventions.
Convention formula_52.
def pddif(x: int, b: int) -> int:
 total = 0
 while x > 0:
 total = total + pow(x % b, x % b)
 x = x // b
 return total
def pddif_cycle(x: int, b: int) -> List[int]:
 seen = []
 while x not in seen:
 seen.append(x)
 x = pddif(x, b)
 cycle = []
 while x not in cycle:
 cycle.append(x)
 x = pddif(x, b)
 return cycle
Convention formula_53.
def pddif(x: int, b: int) -> int:
 total = 0
 while x > 0:
 if x % b > 0:
 total = total + pow(x % b, x % b)
 x = x // b
 return total
def pddif_cycle(x: int, b: int) -> List[int]:
 seen = []
 while x not in seen:
 seen.append(x)
 x = pddif(x, b)
 cycle = []
 while x not in cycle:
 cycle.append(x)
 x = pddif(x, b)
 return cycle
Java.
The following program in Java determines whether an integer number is a Munchausen Number / Perfect Digit to Digit Invariant or not, following the convention formula_20.
import java.util.Scanner;
public class Munchausen
 public static void main ()
 Scanner in = new Scanner (System.in);
 System.out.println("Enter number:");
 int num = in.nextInt(), temp = num, digit; double sum = 0;
 while (num>0)
 { digit = num % 10;
 num /= 10;
 sum += Math.pow(digit, digit);
 
 if (sum == temp)
 System.out.print("Munchausen Number");
 else
 System.out.print("Not Munchausen Number");