In
number theory
Number theory is a branch of pure mathematics devoted primarily to the study of the integers and arithmetic functions. Number theorists study prime numbers as well as the properties of mathematical objects constructed from integers (for example ...
, a perfect digit-to-digit invariant (PDDI; also known as a Munchausen number
) is a
natural number
In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positive in ...
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, as this evokes the story of
Baron Munchausen
Baron Munchausen (; ) is a fictional German nobleman created by the German writer Rudolf Erich Raspe in his 1785 book '' Baron Munchausen's Narrative of His Marvellous Travels and Campaigns in Russia''. The character is loosely based on baron ...
raising himself up by his own ponytail because each digit is raised to the power of itself.
[Daan van Berkel,]
''On a curious property of 3435.''
/ref>
Definition
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.) 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
In mathematics, in the study of iterated functions and dynamical systems, a periodic point of a function (mathematics), function is a point which the system returns to after a certain number of function iterations or a certain amount of time.
It ...
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
Cycle, cycles, or cyclic may refer to:
Anthropology and social sciences
* Cyclic history, a theory of history
* Cyclical theory, a theory of American political history associated with Arthur Schlesinger, Sr.
* Social cycle, various cycles in ...
for any given base .
The number of iterations needed for to reach a fixed point is the -factorion function's persistence
Persistence or Persist may refer to:
Math and computers
* Image persistence, in LCD monitors
* Persistence (computer science), the characteristic of data that outlives the execution of the program that created it
* Persistence of a number, a ma ...
of , and undefined if it never reaches a fixed point.
Perfect digit-to-digit invariants and cycles of Fb for specific b
All numbers are represented in base .
Convention 00 = 1
Convention 00 = 0
Programming examples
The following program in Python
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (prog ...
determines whether an integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
number is a Munchausen Number / Perfect Digit to Digit Invariant or not, following the convention .
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 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
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (prog ...
for the two conventions.
Convention 00 = 1
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 nt
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 00 = 0
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 nt
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
See also
* Arithmetic dynamics
Arithmetic dynamics is a field that amalgamates two areas of mathematics, dynamical systems and number theory. Part of the inspiration comes from complex dynamics, the study of the Iterated function, iteration of self-maps of the complex plane or o ...
* Dudeney number
* Factorion
* Happy number
In number theory, a happy number is a number which eventually reaches 1 when the number is replaced by the sum of the square of each digit. For instance, 13 is a happy number because 1^2+3^2=10, and 1^2+0^2=1. On the other hand, 4 is not a happy ...
* Kaprekar's constant
In number theory, Kaprekar's routine is an iterative algorithm named after its inventor, Indian mathematician D. R. Kaprekar. Each iteration starts with a four-digit random number, sorts the digits into descending and ascending order, and calculate ...
* Kaprekar number
In mathematics, a natural number in a given number base is a p-Kaprekar number if the representation of its square in that base can be split into two parts, where the second part has p digits, that add up to the original number. For example, in ...
* Meertens number
* Narcissistic number
* Perfect digital invariant
* Sum-product number
References
External links
*
{{Classes of natural numbers
Arithmetic dynamics
Base-dependent integer sequences
Articles with example Python (programming language) code