In
number theory
Number theory (or arithmetic or higher arithmetic in older usage) is a branch of pure mathematics devoted primarily to the study of the integers and integer-valued functions. German mathematician Carl Friedrich Gauss (1777–1855) said, "Math ...
, a narcissistic number
[''Perfect and PluPerfect Digital Invariants''](_blank)
by Scott Moore (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
In a positional numeral system, the radix or base is the number of unique digits, including the digit zero, used to represent numbers. For example, for the decimal/denary system (the most common system in use today) the radix (base number) is t ...
is a number that is the sum of its own digits each raised to the power of the number of digits.
Definition
Let
be a natural number. We define the narcissistic function for base
to be the following:
:
where
is the number of digits in the number in base
, and
:
is the value of each digit of the number. A natural number
is a narcissistic number if it is a
fixed point for
, which occurs if
. The natural numbers
are trivial narcissistic numbers for all
, all other narcissistic numbers are nontrivial narcissistic numbers.
For example, the number 153 in base
is a narcissistic number, because
and
.
A natural number
is a sociable narcissistic number if it is a
periodic point In mathematics, in the study of iterated functions and dynamical systems, a periodic point of a function is a point which the system returns to after a certain number of function iterations or a certain amount of time.
Iterated functions
Given ...
for
, where
for a positive
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
(here
is the
th
iterate
Iteration is the repetition of a process in order to generate a (possibly unbounded) sequence of outcomes. Each repetition of the process is a single iteration, and the outcome of each iteration is then the starting point of the next iteration. ...
of
), and forms a
cycle
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 so ...
of period
. A narcissistic number is a sociable narcissistic number with
, and an amicable narcissistic number is a sociable narcissistic number with
.
All natural numbers
are
preperiodic points for
, regardless of the base. This is because for any given digit count
, the minimum possible value of
is
, the maximum possible value of
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
where
, because of the
exponential
Exponential may refer to any of several mathematical topics related to exponentiation, including:
*Exponential function, also:
**Matrix exponential, the matrix analogue to the above
*Exponential decay, decrease at a rate proportional to value
* Exp ...
nature of
and the
linearity
Linearity is the property of a mathematical relationship ('' function'') that can be graphically represented as a straight line. Linearity is closely related to '' proportionality''. Examples in physics include rectilinear motion, the linear ...
of
. Beyond this value
,
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
, making it a preperiodic point. Setting
equal to 10 shows that the largest narcissistic number in base 10 must be less than
.
The number of iterations
needed for
to reach a fixed point is the narcissistic function's
persistence of
, and undefined if it never reaches a fixed point.
A base
has at least one two-digit narcissistic number
if and only if
In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false.
The connective is bi ...
is not prime, and the number of two-digit narcissistic numbers in base
equals
, where
is the number of positive divisors of
.
Every base
that is not a multiple of nine has at least one three-digit narcissistic number. The bases that do not are
:2, 72, 90, 108, 153, 270, 423, 450, 531, 558, 630, 648, 738, 1044, 1098, 1125, 1224, 1242, 1287, 1440, 1503, 1566, 1611, 1620, 1800, 1935, ...
There are only 89 narcissistic numbers in base 10, of which the largest is
:115,132,219,018,763,992,565,095,597,973,971,522,401
with 39 digits.
Narcissistic numbers and cycles of ''F''''b'' for specific ''b''
All numbers are represented in base
. '#' 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
In mathematical notation for numbers, a signed-digit representation is a positional numeral system with a set of signed digits used to encode the integers.
Signed-digit representation can be used to accomplish fast addition of integers because ...
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.
def ppdif(x, b):
y = x
digit_count = 0
while y > 0:
digit_count = digit_count + 1
y = y // b
total = 0
while x > 0:
total = total + pow(x % b, digit_count)
x = x // b
return total
def ppdif_cycle(x, b):
seen = []
while x not in seen:
seen.append(x)
x = ppdif(x, b)
cycle = []
while x not in cycle:
cycle.append(x)
x = ppdif(x, b)
return cycle
The following Python program determines whether the
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
entered is a Narcissistic / Armstrong number or not.
def no_of_digits(num):
i = 0
while num > 0:
num //= 10
i+=1
return i
def required_sum(num):
i = no_of_digits(num)
s = 0
while num > 0:
digit = num % 10
num //= 10
s += pow(digit, i)
return s
num = int(input("Enter number:"))
s = required_sum(num)
if s num:
print("Armstrong Number")
else:
print("Not Armstrong Number")
Java
The following
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
program determines whether the
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
entered is a Narcissistic / Armstrong number or not.
import java.util.Scanner;
public class ArmstrongNumber
C#
The following
C# program determines whether the
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
entered is a Narcissistic / Armstrong number or not.
using System;
public class Program
C
The following
C program determines whether the
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
entered is a Narcissistic / Armstrong number or not.
#include
#include
#include
int getNumberOfDigits(int n);
bool isArmstrongNumber(int candidate);
int main()
bool isArmstrongNumber(int candidate)
int getNumberOfDigits(int n)
C++
The following
C++ program determines whether the
Integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
entered is a Narcissistic / Armstrong number or not.
#include
#include
bool isNarcissistic(long n)
int main()
Ruby
The following
Ruby
A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum (aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapp ...
program determines whether the
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
entered is a Narcissistic / Armstrong number or not.
def narcissistic?(value) #1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
nvalue = []
nnum = value.to_s
nnum.each_char do , num,
nvalue << num.to_i
end
sum = 0
i = 0
while sum <= value
nsum = 0
nvalue.each_with_index do , num,idx,
nsum += num ** i
end
if nsum value
return true
else
i += 1
sum += nsum
end
end
return false
end
See also
*
Arithmetic dynamics Arithmetic dynamics is a field that amalgamates two areas of mathematics, dynamical systems and number theory. Classically, discrete dynamics refers to the study of the iteration of self-maps of the complex plane or real line. Arithmetic dynamics is ...
*
Dudeney number In number theory, a Dudeney number in a given number base b is a natural number equal to the perfect cube of another natural number such that the digit sum of the first natural number is equal to the second. The name derives from Henry Dudeney, ...
*
Factorion In number theory, a factorion in a given number base b is a natural number that equals the sum of the factorials of its digits. The name factorion was coined by the author Clifford A. Pickover.
Definition
Let n be a natural number. For a base b ...
*
Happy number
In number theory, a happy number is a number which eventually reaches 1 when 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 number because ...
*
Kaprekar's constant
*
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. The numbers are ...
*
Meertens number In number theory and mathematical logic, a Meertens number in a given number base b is a natural number that is its own Gödel number. It was named after Lambert Meertens by Richard S. Bird as a present during the celebration of his 25 years at t ...
*
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 b that is equal to the sum of its digits each raised to the power of itself. An example in base 10 is 3435, be ...
*
Perfect digital invariant In number theory, a perfect digital invariant (PDI) is a number in a given number base (b) that is the sum of its own digits each raised to a given power (p). 0 F_ : \mathbb \rightarrow \mathbb is defined as:
:F_(n) = \sum_^ d_i^p.
where k = \lfl ...
*
Sum-product number
A sum-product number in a given number base b is a natural number that is equal to the product of the sum of its digits and the product of its digits.
There are a finite number of sum-product numbers in any given base b. 1 F_ : \mathbb \rightarr ...
References
*
Joseph S. Madachy, ''Mathematics on Vacation'', Thomas Nelson & Sons Ltd. 1966, pages 163-175.
* Rose, Colin (2005), ''Radical narcissistic numbers'', Journal of Recreational Mathematics, 33(4), 2004-2005, pages 250-254.
''Perfect Digital Invariants''by Walter Schneider
External links
Armstrong NumbersArmstrong Numbers in base 2 to 16*
{{Classes of natural numbers
Arithmetic dynamics
Base-dependent integer sequences