Contents
Narcissistic number
In number theory, a narcissistic number (also known as a pluperfect digital invariant (PPDI), an Armstrong number (after Michael F. Armstrong) or a plus perfect number) in a given number base b is a number that is the sum of its own digits each raised to the power of the number of digits.
Definition
Let n be a natural number. We define the narcissistic function for base b > 1 to be the following: where is the number of digits in the number in base b, and is the value of each digit of the number. A natural number n is a narcissistic number if it is a fixed point for F_{b}, which occurs if. The natural numbers are trivial narcissistic numbers for all b, all other narcissistic numbers are nontrivial narcissistic numbers. For example, the number 153 in base b = 10 is a narcissistic number, because k = 3 and. A natural number n is a sociable narcissistic number if it is a periodic point for F_{b}, where for a positive integer p (here F_{b}^p is the pth iterate of F_b), and forms a cycle of period p. A narcissistic number is a sociable narcissistic number with p = 1, and an amicable narcissistic number is a sociable narcissistic number with p = 2. All natural numbers n are preperiodic points for F_{b}, regardless of the base. This is because for any given digit count k, the minimum possible value of n is b^{k - 1}, the maximum possible value of n is, and the narcissistic function value is. Thus, any narcissistic number must satisfy the inequality. Multiplying all sides by, we get , or equivalently,. Since, this means that there will be a maximum value k where , because of the exponential nature of and the linearity of bk. Beyond this value k, always. Thus, there are a finite number of narcissistic numbers, and any natural number is guaranteed to reach a periodic point or a fixed point less than b^{k} - 1, making it a preperiodic point. Setting b equal to 10 shows that the largest narcissistic number in base 10 must be less than 10^{60}. The number of iterations i needed for to reach a fixed point is the narcissistic function's persistence of n, and undefined if it never reaches a fixed point. A base b has at least one two-digit narcissistic number if and only if b^2 + 1 is not prime, and the number of two-digit narcissistic numbers in base b equals, where \tau(n) is the number of positive divisors of n. Every base b \geq 3 that is not a multiple of nine has at least one three-digit narcissistic number. The bases that do not are There are only 88 narcissistic numbers in base 10, of which the largest is with 39 digits.
Narcissistic numbers and cycles of Fb for specific b
All numbers are represented in base b. '#' is the length of each known finite sequence.
Extension to negative integers
Narcissistic numbers can be extended to the negative integers by use of a signed-digit representation to represent each integer.
Programming example
Python
The example below implements the narcissistic function described in the definition above to search for narcissistic functions and cycles in Python. The following Python program determines whether the integer entered is a Narcissistic / Armstrong number or not.
Java
The following Java program determines whether the integer entered is a Narcissistic / Armstrong number or not.
C#
The following C# program determines whether the integer entered is a Narcissistic / Armstrong number or not.
C
The following C program determines whether the integer entered is a Narcissistic / Armstrong number or not.
C++
The following C++ program determines whether the Integer entered is a Narcissistic / Armstrong number or not.
Ruby
The following Ruby program determines whether the integer entered is a Narcissistic / Armstrong number or not.
JavaScript
The following JavaScript program determines whether the integer entered is a Narcissistic / Armstrong number or not.
Rust
The following Rust program prints all the Narcissistic / Armstrong numbers from 0 to 100 million in base 10.
This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.
Wikipedia® is a registered trademark of the
Wikimedia Foundation, Inc.
Bliptext is not
affiliated with or endorsed by Wikipedia or the
Wikimedia Foundation.