A Munchausen Number in base \$b\$, also known as a Perfect digit-to-digit invariant or PDDI is a peculiar type of positive integer where the sum of its base-\$b\$ digits raised to themselves is equal to the number itself. They are named for the fictional Baron Munchausen, who apparently hoisted himself up via his own ponytail to save himself from drowning. A related concept is Narcissistic numbers.
For instance, \$1\$ is trivially a Munchausen number in every base because \$1^1=1\$. Additionally, every positive integer is a base-1 Munchausen number by definition.
More interestingly, \$3435\$ is a base-10 Munchausen number because \$3^3+4^4+3^3+5^5=3435\$, and in fact is the only other base-10 Munchausen number.
A partial list of Munchausen numbers in every base up to 35 can be found on the OEIS as sequence A166623.
Given a positive integer \$n>0\$, determine if it is a Munchausen number in any base \$b\geq2\$.
- Default I/O rules apply, so:
- Full program or functions are acceptable.
- Input can be from STDIN, as a function argument, and output can be to STDOUT, as a function return value, etc.
- Default loopholes apply.
- The output must be one of two distinct, consistent results. So
TRUEis fine for truthy and
FALSEis fine for falsy, but you can reverse that or return
Nonefor truthy and
1for falsy or whatever. Please specify the selected results in your answer.
- Your answer has to work at least theoretically for any positive integer.
- Munchausen numbers use the convention \$0^0=1\$, so \$2\$ is a base-2 Munchausen number as \$1^1+0^0=2\$. Your code must follow this convention.
- Explanations are strongly encouraged, even though submissions will most likely use the brute-force search method.
- Using esoteric languages earns you brownie points since Munchausen was apparently a strange person.
Truthy 1 (all bases) 2 (base 2) 5 (base 3) 28 (base 9 and base 25) 29 (base 4) 55 (base 4) 3435 (base 10) 923362 (base 9) 260 (base 128) 257 (base 64 and base 253) Falsy 3 4 591912 3163 17
This is code-golf, so the shortest answer in each language (in bytes) wins!