In number theory, a perfect digit-to-digit invariant (PDDI; also known as a Munchausen number [1] ) is a natural number in a given number base that is equal to the sum of its digits each raised to the power of itself. An example in base 10 is 3435, because . The term "Munchausen number" was coined by Dutch mathematician and software engineer Daan van Berkel in 2009, [2] 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. [3] [4]
Let be a natural number which can be written in base as the k-digit number where each digit is between and inclusive, and . We define the function as . (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. [5] [6] ) A natural number is defined to be a perfect digit-to-digit invariant in base b if . For example, the number 3435 is a perfect digit-to-digit invariant in base 10 because .
for all , and thus 1 is a trivial perfect digit-to-digit invariant in all bases, and all other perfect digit-to-digit invariants are nontrivial. For the second convention where , both and are trivial perfect digit-to-digit invariants.
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 . An 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.
All numbers are represented in base .
| Base | Nontrivial perfect digit-to-digit invariants () | Cycles |
|---|---|---|
| 2 | 10 | |
| 3 | 12, 22 | 2 → 11 → 2 |
| 4 | 131, 313 | 2 → 10 → 2 |
| 5 | 2 → 4 → 2011 → 12 → 10 → 2 104 → 2013 → 113 → 104 | |
| 6 | 22352, 23452 | 4 → 1104 → 1111 → 4 23445 → 24552 → 50054 → 50044 → 24503 → 23445 |
| 7 | 13454 | 12066 → 536031 → 265204 → 265623 → 551155 → 51310 → 12125 → 12066 |
| 8 | 405 → 6466 → 421700 → 3110776 → 6354114 → 142222 → 421 → 405 | |
| 9 | 31, 156262, 1656547 | |
| 10 | 3435 | |
| 11 | 18453278, 18453487 | |
| 12 | 3A67A54832 | |
| 13 | 33661, 2AA834668A, 4CA92A233518, 4CA92A233538 | |
| 14 | 23, 26036, 45A0A04513CC, A992B5D96720D | |
| 15 | 4B1648420DCD0, 5A99E538339A43, 5ACBC41C19E333, 5ACBC41C19E400, 5D0B197C25E056 | |
| 16 | C4EF722B782C26F, C76712FFC311E6E | |
| 17 | 33 | |
| 18 | ||
| 19 | ||
| 20 | 6534 | |
| 21 | ||
| 22 | ||
| 23 | ||
| 24 | ||
| 25 | 13, 513 |
| Base | Nontrivial perfect digit-to-digit invariants (, ) [1] | Cycles |
|---|---|---|
| 2 | ||
| 3 | 12, 22 | 2 → 11 → 2 |
| 4 | 130, 131, 313 | |
| 5 | 103, 2024 | 2 → 4 → 2011 → 11 → 2 9 → 2012 → 9 |
| 6 | 22352, 23452 | 5 → 22245 → 23413 → 1243 → 1200 → 5 53 → 22332 → 150 → 22250 → 22305 → 22344 → 2311 → 53 |
| 7 | 13454 | |
| 8 | 400, 401 | |
| 9 | 30, 31, 156262, 1647063, 1656547, 34664084 | |
| 10 | 3435, 438579088 | |
| 11 | ||
| 12 | 3A67A54832 |
The following program in Python determines whether an integer number is a Munchausen Number / Perfect Digit to Digit Invariant or not, following the convention .
num=int(input("Enter number:"))temp=nums=0.0whilenum>0:digit=num%10num//=10s+=pow(digit,digit)ifs==temp:print("Munchausen Number")else:print("Not Munchausen Number")The examples below implement 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.
defpddif(x:int,b:int)->int:total=0whilex>0:total=total+pow(x%b,x%b)x=x//breturntotaldefpddif_cycle(x:int,b:int)->list[int]:seen=[]whilexnotinseen:seen.append(x)x=pddif(x,b)cycle=[]whilexnotincycle:cycle.append(x)x=pddif(x,b)returncycledefpddif(x:int,b:int)->int:total=0whilex>0:ifx%b>0:total=total+pow(x%b,x%b)x=x//breturntotaldefpddif_cycle(x:int,b:int)->list[int]:seen=[]whilexnotinseen:seen.append(x)x=pddif(x,b)cycle=[]whilexnotincycle:cycle.append(x)x=pddif(x,b)returncycle