Perfect digital invariant

In number theory, a perfect digital invariant (PDI) is a number in a given number base ( b {\displaystyle b} ) that is the sum of its own digits each raised to a given power ( p {\displaystyle p} ).[1][2]

Definition

Let n {\displaystyle n} be a natural number. The perfect digital invariant function (also known as a happy function, from happy numbers) for base b > 1 {\displaystyle b>1} and power p > 0 {\displaystyle p>0} F p , b : N N {\displaystyle F_{p,b}:\mathbb {N} \rightarrow \mathbb {N} } is defined as:

F p , b ( n ) = i = 0 k 1 d i p . {\displaystyle F_{p,b}(n)=\sum _{i=0}^{k-1}d_{i}^{p}.}

where k = log b n + 1 {\displaystyle k=\lfloor \log _{b}{n}\rfloor +1} is the number of digits in the number in base b {\displaystyle b} , and

d i = n mod b i + 1 n mod b i b i {\displaystyle d_{i}={\frac {n{\bmod {b^{i+1}}}-n{\bmod {b}}^{i}}{b^{i}}}}

is the value of each digit of the number. A natural number n {\displaystyle n} is a perfect digital invariant if it is a fixed point for F p , b {\displaystyle F_{p,b}} , which occurs if F p , b ( n ) = n {\displaystyle F_{p,b}(n)=n} . 0 {\displaystyle 0} and 1 {\displaystyle 1} are trivial perfect digital invariants for all b {\displaystyle b} and p {\displaystyle p} , all other perfect digital invariants are nontrivial perfect digital invariants.

For example, the number 4150 in base b = 10 {\displaystyle b=10} is a perfect digital invariant with p = 5 {\displaystyle p=5} , because 4150 = 4 5 + 1 5 + 5 5 + 0 5 {\displaystyle 4150=4^{5}+1^{5}+5^{5}+0^{5}} .

A natural number n {\displaystyle n} is a sociable digital invariant if it is a periodic point for F p , b {\displaystyle F_{p,b}} , where F p , b k ( n ) = n {\displaystyle F_{p,b}^{k}(n)=n} for a positive integer k {\displaystyle k} (here F p , b k {\displaystyle F_{p,b}^{k}} is the k {\displaystyle k} th iterate of F p , b {\displaystyle F_{p,b}} ), and forms a cycle of period k {\displaystyle k} . A perfect digital invariant is a sociable digital invariant with k = 1 {\displaystyle k=1} , and a amicable digital invariant is a sociable digital invariant with k = 2 {\displaystyle k=2} .

All natural numbers n {\displaystyle n} are preperiodic points for F p , b {\displaystyle F_{p,b}} , regardless of the base. This is because if k p + 2 {\displaystyle k\geq p+2} , n b k 1 > b p k {\displaystyle n\geq b^{k-1}>b^{p}k} , so any n {\displaystyle n} will satisfy n > F b , p ( n ) {\displaystyle n>F_{b,p}(n)} until n < b p + 1 {\displaystyle n<b^{p+1}} . There are a finite number of natural numbers less than b p + 1 {\displaystyle b^{p+1}} , so the number is guaranteed to reach a periodic point or a fixed point less than b p + 1 {\displaystyle b^{p+1}} , making it a preperiodic point.

Numbers in base b > p {\displaystyle b>p} lead to fixed or periodic points of numbers n ( p 2 ) p + p ( b 1 ) p {\displaystyle n\leq (p-2)^{p}+p(b-1)^{p}} .

Proof

If b > p {\displaystyle b>p} , then the n < b p + 1 {\displaystyle n<b^{p+1}} bound can be reduced. Let r {\displaystyle r} be the number for which the sum of squares of digits is largest among the numbers less than b p {\displaystyle b^{p}} .

r = b p 1 = t = 0 p ( b 1 ) b t {\displaystyle r=b^{p}-1=\sum _{t=0}^{p}(b-1)b^{t}}
F p , b ( r ) = ( p + 1 ) ( b 1 ) p < ( p + 1 ) b p b p + 1 {\displaystyle F_{p,b}(r)=(p+1)(b-1)^{p}<(p+1)b^{p}\leq b^{p+1}} because b ( p + 1 ) {\displaystyle b\geq (p+1)}

Let s {\displaystyle s} be the number for which the sum of squares of digits is largest among the numbers less than ( p + 1 ) ( b 1 ) p {\displaystyle (p+1)(b-1)^{p}} .

s = ( p + 1 ) b p 1 = p b p + t = 0 p 1 ( b 1 ) b t {\displaystyle s=(p+1)b^{p}-1=pb^{p}+\sum _{t=0}^{p-1}(b-1)b^{t}}
F p , b ( s ) = p p + p ( b 1 ) p < p b p {\displaystyle F_{p,b}(s)=p^{p}+p(b-1)^{p}<pb^{p}} because b p {\displaystyle b\geq p}

Let t {\displaystyle t} be the number for which the sum of squares of digits is largest among the numbers less than p b p {\displaystyle pb^{p}} .

t = ( p 1 ) b p + t = 0 p 1 ( b 1 ) b t {\displaystyle t=(p-1)b^{p}+\sum _{t=0}^{p-1}(b-1)b^{t}}
F p , b ( t ) = ( p 1 ) p + p ( b 1 ) p {\displaystyle F_{p,b}(t)=(p-1)^{p}+p(b-1)^{p}}

Let u {\displaystyle u} be the number for which the sum of squares of digits is largest among the numbers less than F p , b ( t ) + 1 {\displaystyle F_{p,b}(t)+1} .

u = ( p 2 ) b p + t = 0 p 1 ( b 1 ) b t {\displaystyle u=(p-2)b^{p}+\sum _{t=0}^{p-1}(b-1)b^{t}}
F p , b ( u ) = ( p 2 ) p + p ( b 1 ) p < ( p 1 ) p + p ( b 1 ) p = n + 1 {\displaystyle F_{p,b}(u)=(p-2)^{p}+p(b-1)^{p}<(p-1)^{p}+p(b-1)^{p}=n_{\ell +1}}

u F p , b ( u ) < F p , b ( t ) {\displaystyle u\leq F_{p,b}(u)<F_{p,b}(t)} . Thus, numbers in base b > p {\displaystyle b>p} lead to cycles or fixed points of numbers n F p , b ( u ) = ( p 1 ) p + p ( b 1 ) p {\displaystyle n\leq F_{p,b}(u)=(p-1)^{p}+p(b-1)^{p}} .

The number of iterations i {\displaystyle i} needed for F p , b i ( n ) {\displaystyle F_{p,b}^{i}(n)} to reach a fixed point is the perfect digital invariant function's persistence of n {\displaystyle n} , and undefined if it never reaches a fixed point.

F 1 , b {\displaystyle F_{1,b}} is the digit sum. The only perfect digital invariants are the single-digit numbers in base b {\displaystyle b} , and there are no periodic points with prime period greater than 1.

F p , 2 {\displaystyle F_{p,2}} reduces to F 1 , 2 {\displaystyle F_{1,2}} , as for any power p {\displaystyle p} , 0 p = 0 {\displaystyle 0^{p}=0} and 1 p = 1 {\displaystyle 1^{p}=1} .

For every natural number k > 1 {\displaystyle k>1} , if p < b {\displaystyle p<b} , ( b 1 ) 0 mod k {\displaystyle (b-1)\equiv 0{\bmod {k}}} and ( p 1 ) 0 mod ϕ ( k ) {\displaystyle (p-1)\equiv 0{\bmod {\phi }}(k)} , then for every natural number n {\displaystyle n} , if n m mod k {\displaystyle n\equiv m{\bmod {k}}} , then F p , b ( n ) m mod k {\displaystyle F_{p,b}(n)\equiv m{\bmod {k}}} , where ϕ ( k ) {\displaystyle \phi (k)} is Euler's totient function.

Proof

Let

n = i = 0 j d i b i {\displaystyle n=\sum _{i=0}^{j}d_{i}b^{i}}

be a natural number with j {\displaystyle j} digits, where 0 d i < b {\displaystyle 0\leq d_{i}<b} , and ( b 1 ) 0 mod k {\displaystyle (b-1)\equiv 0{\bmod {k}}} , where k {\displaystyle k} is a natural number greater than 1.

According to the divisibility rules of base b {\displaystyle b} , if b 1 0 mod k {\displaystyle b-1\equiv 0{\bmod {k}}} , then if n m mod k {\displaystyle n\equiv m{\bmod {k}}} , then the digit sum

F 1 , b ( n ) = i = 0 j d i m mod k {\displaystyle F_{1,b}(n)=\sum _{i=0}^{j}d_{i}\equiv m{\bmod {k}}}

If a digit d i m mod k {\displaystyle d_{i}\equiv m{\bmod {k}}} , then d i p m p mod k {\displaystyle d_{i}^{p}\equiv m^{p}{\bmod {k}}} . According to Euler's theorem, if ( p 1 ) 0 mod ϕ ( k ) {\displaystyle (p-1)\equiv 0{\bmod {\phi }}(k)} , m p mod k = m mod k {\displaystyle m^{p}{\bmod {k}}=m{\bmod {k}}} . Thus, if the digit sum F 1 , b ( n ) m mod k {\displaystyle F_{1,b}(n)\equiv m{\bmod {k}}} , then F p , b ( n ) m mod k {\displaystyle F_{p,b}(n)\equiv m{\bmod {k}}} .

Therefore, for any natural number k {\displaystyle k} , if p < b {\displaystyle p<b} , ( b 1 ) 0 mod k {\displaystyle (b-1)\equiv 0{\bmod {k}}} and ( p 1 ) 0 mod ϕ ( k ) {\displaystyle (p-1)\equiv 0{\bmod {\phi }}(k)} , then for every natural number n {\displaystyle n} , if n m mod k {\displaystyle n\equiv m{\bmod {k}}} , then F p , b ( n ) m mod k {\displaystyle F_{p,b}(n)\equiv m{\bmod {k}}} .

No upper bound can be determined for the size of perfect digital invariants in a given base and arbitrary power, and it is not currently known whether or not the number of perfect digital invariants for an arbitrary base is finite or infinite.[1]

F2,b

By definition, any three-digit perfect digital invariant n = d 2 d 1 d 0 {\displaystyle n=d_{2}d_{1}d_{0}} for F 2 , b {\displaystyle F_{2,b}} with natural number digits 0 d 0 < b {\displaystyle 0\leq d_{0}<b} , 0 d 1 < b {\displaystyle 0\leq d_{1}<b} , 0 d 2 < b {\displaystyle 0\leq d_{2}<b} has to satisfy the cubic Diophantine equation d 0 2 + d 1 2 + d 2 2 = d 2 b 2 + d 1 b + d 0 {\displaystyle d_{0}^{2}+d_{1}^{2}+d_{2}^{2}=d_{2}b^{2}+d_{1}b+d_{0}} . d 2 {\displaystyle d_{2}} has to be equal to 0 or 1 for any b > 2 {\displaystyle b>2} , because the maximum value n {\displaystyle n} can take is n = ( 2 1 ) 2 + 2 ( b 1 ) 2 = 1 + 2 ( b 1 ) 2 < 2 b 2 {\displaystyle n=(2-1)^{2}+2(b-1)^{2}=1+2(b-1)^{2}<2b^{2}} . As a result, there are actually two related quadratic Diophantine equations to solve:

d 0 2 + d 1 2 = d 1 b + d 0 {\displaystyle d_{0}^{2}+d_{1}^{2}=d_{1}b+d_{0}} when d 2 = 0 {\displaystyle d_{2}=0} , and
d 0 2 + d 1 2 + 1 = b 2 + d 1 b + d 0 {\displaystyle d_{0}^{2}+d_{1}^{2}+1=b^{2}+d_{1}b+d_{0}} when d 2 = 1 {\displaystyle d_{2}=1} .

The two-digit natural number n = d 1 d 0 {\displaystyle n=d_{1}d_{0}} is a perfect digital invariant in base

b = d 1 + d 0 ( d 0 1 ) d 1 . {\displaystyle b=d_{1}+{\frac {d_{0}(d_{0}-1)}{d_{1}}}.}

This can be proven by taking the first case, where d 2 = 0 {\displaystyle d_{2}=0} , and solving for b {\displaystyle b} . This means that for some values of d 0 {\displaystyle d_{0}} and d 1 {\displaystyle d_{1}} , n {\displaystyle n} is not a perfect digital invariant in any base, as d 1 {\displaystyle d_{1}} is not a divisor of d 0 ( d 0 1 ) {\displaystyle d_{0}(d_{0}-1)} . Moreover, d 0 > 1 {\displaystyle d_{0}>1} , because if d 0 = 0 {\displaystyle d_{0}=0} or d 0 = 1 {\displaystyle d_{0}=1} , then b = d 1 {\displaystyle b=d_{1}} , which contradicts the earlier statement that 0 d 1 < b {\displaystyle 0\leq d_{1}<b} .

There are no three-digit perfect digital invariants for F 2 , b {\displaystyle F_{2,b}} , which can be proven by taking the second case, where d 2 = 1 {\displaystyle d_{2}=1} , and letting d 0 = b a 0 {\displaystyle d_{0}=b-a_{0}} and d 1 = b a 1 {\displaystyle d_{1}=b-a_{1}} . Then the Diophantine equation for the three-digit perfect digital invariant becomes

( b a 0 ) 2 + ( b a 1 ) 2 + 1 = b 2 + ( b a 1 ) b + ( b a 0 ) {\displaystyle (b-a_{0})^{2}+(b-a_{1})^{2}+1=b^{2}+(b-a_{1})b+(b-a_{0})}
b 2 2 a 0 b + a 0 2 + b 2 2 a 1 b + a 1 2 + 1 = b 2 + ( b a 1 ) b + ( b a 0 ) {\displaystyle b^{2}-2a_{0}b+a_{0}^{2}+b^{2}-2a_{1}b+a_{1}^{2}+1=b^{2}+(b-a_{1})b+(b-a_{0})}
2 b 2 2 ( a 0 + a 1 ) b + a 0 2 + a 1 2 + 1 = b 2 + ( b a 1 ) b + ( b a 0 ) {\displaystyle 2b^{2}-2(a_{0}+a_{1})b+a_{0}^{2}+a_{1}^{2}+1=b^{2}+(b-a_{1})b+(b-a_{0})}
b 2 + ( b 2 ( a 0 + a 1 ) ) b + a 0 2 + a 1 2 + 1 = b 2 + ( b a 1 ) b + ( b a 0 ) {\displaystyle b^{2}+(b-2(a_{0}+a_{1}))b+a_{0}^{2}+a_{1}^{2}+1=b^{2}+(b-a_{1})b+(b-a_{0})}

2 ( a 0 + a 1 ) > a 1 {\displaystyle 2(a_{0}+a_{1})>a_{1}} for all values of 0 < a 1 b {\displaystyle 0<a_{1}\leq b} . Thus, there are no solutions to the Diophantine equation, and there are no three-digit perfect digital invariants for F 2 , b {\displaystyle F_{2,b}} .

F3,b

There are just four numbers, after unity, which are the sums of the cubes of their digits:

153 = 1 3 + 5 3 + 3 3 {\displaystyle 153=1^{3}+5^{3}+3^{3}}
370 = 3 3 + 7 3 + 0 3 {\displaystyle 370=3^{3}+7^{3}+0^{3}}
371 = 3 3 + 7 3 + 1 3 {\displaystyle 371=3^{3}+7^{3}+1^{3}}
407 = 4 3 + 0 3 + 7 3 . {\displaystyle 407=4^{3}+0^{3}+7^{3}.}
These are odd facts, very suitable for puzzle columns and likely to amuse amateurs, but there is nothing in them which appeals to the mathematician. (sequence A046197 in the OEIS)
— G. H. Hardy, A Mathematician's Apology

By definition, any four-digit perfect digital invariant n {\displaystyle n} for F 3 , b {\displaystyle F_{3,b}} with natural number digits 0 d 0 < b {\displaystyle 0\leq d_{0}<b} , 0 d 1 < b {\displaystyle 0\leq d_{1}<b} , 0 d 2 < b {\displaystyle 0\leq d_{2}<b} , 0 d 3 < b {\displaystyle 0\leq d_{3}<b} has to satisfy the quartic Diophantine equation d 0 3 + d 1 3 + d 2 3 + d 3 3 = d 3 b 3 + d 2 b 2 + d 1 b + d 0 {\displaystyle d_{0}^{3}+d_{1}^{3}+d_{2}^{3}+d_{3}^{3}=d_{3}b^{3}+d_{2}b^{2}+d_{1}b+d_{0}} . d 3 {\displaystyle d_{3}} has to be equal to 0, 1, 2 for any b > 3 {\displaystyle b>3} , because the maximum value n {\displaystyle n} can take is n = ( 3 2 ) 3 + 3 ( b 1 ) 3 = 1 + 3 ( b 1 ) 3 < 3 b 3 {\displaystyle n=(3-2)^{3}+3(b-1)^{3}=1+3(b-1)^{3}<3b^{3}} . As a result, there are actually three related cubic Diophantine equations to solve

d 0 3 + d 1 3 + d 2 3 = d 2 b 2 + d 1 b + d 0 {\displaystyle d_{0}^{3}+d_{1}^{3}+d_{2}^{3}=d_{2}b^{2}+d_{1}b+d_{0}} when d 3 = 0 {\displaystyle d_{3}=0}
d 0 3 + d 1 3 + d 2 3 + 1 = b 3 + d 2 b 2 + d 1 b + d 0 {\displaystyle d_{0}^{3}+d_{1}^{3}+d_{2}^{3}+1=b^{3}+d_{2}b^{2}+d_{1}b+d_{0}} when d 3 = 1 {\displaystyle d_{3}=1}
d 0 3 + d 1 3 + d 2 3 + 8 = 2 b 3 + d 2 b 2 + d 1 b + d 0 {\displaystyle d_{0}^{3}+d_{1}^{3}+d_{2}^{3}+8=2b^{3}+d_{2}b^{2}+d_{1}b+d_{0}} when d 3 = 2 {\displaystyle d_{3}=2}

We take the first case, where d 3 = 0 {\displaystyle d_{3}=0} .

b = 3k + 1

Let k {\displaystyle k} be a positive integer and the number base b = 3 k + 1 {\displaystyle b=3k+1} . Then:

  • n 1 = k b 2 + ( 2 k + 1 ) b {\displaystyle n_{1}=kb^{2}+(2k+1)b} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .
Proof

Let the digits of n 1 = d 2 b 2 + d 1 b + d 0 {\displaystyle n_{1}=d_{2}b^{2}+d_{1}b+d_{0}} be d 2 = k {\displaystyle d_{2}=k} , d 1 = 2 k + 1 {\displaystyle d_{1}=2k+1} , and d 0 = 0 {\displaystyle d_{0}=0} . Then

F 3 , b ( n 1 ) = d 0 3 + d 1 3 + d 2 3 = k 3 + ( 2 k + 1 ) 3 + 0 3 = ( k 2 k ( 2 k + 1 ) + ( 2 k + 1 ) 2 ) ( k + ( 2 k + 1 ) ) = ( k 2 2 k 2 k + 4 k 2 + 4 k + 1 ) ( 3 k + 1 ) = ( 3 k 2 + 3 k + 1 ) ( 3 k + 1 ) = ( 3 k 2 + 4 k + 1 ) ( 3 k + 1 ) k ( 3 k + 1 ) = ( k + 1 ) ( 3 k + 1 ) ( 3 k + 1 ) k ( 3 k + 1 ) = k ( 3 k + 1 ) ( 3 k + 1 ) + ( 3 k + 1 ) ( 3 k + 1 ) k ( 3 k + 1 ) = k ( 3 k + 1 ) 2 + ( 2 k + 1 ) ( 3 k + 1 ) + 0 = d 2 b 2 + d 1 b + d 0 = n 1 {\displaystyle {\begin{aligned}F_{3,b}(n_{1})&=d_{0}^{3}+d_{1}^{3}+d_{2}^{3}\\&=k^{3}+(2k+1)^{3}+0^{3}\\&=(k^{2}-k(2k+1)+(2k+1)^{2})(k+(2k+1))\\&=(k^{2}-2k^{2}-k+4k^{2}+4k+1)(3k+1)\\&=(3k^{2}+3k+1)(3k+1)\\&=(3k^{2}+4k+1)(3k+1)-k(3k+1)\\&=(k+1)(3k+1)(3k+1)-k(3k+1)\\&=k(3k+1)(3k+1)+(3k+1)(3k+1)-k(3k+1)\\&=k(3k+1)^{2}+(2k+1)(3k+1)+0\\&=d_{2}b^{2}+d_{1}b+d_{0}\\&=n_{1}\end{aligned}}}

Thus n 1 {\displaystyle n_{1}} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .

  • n 2 = k b 2 + ( 2 k + 1 ) b + 1 {\displaystyle n_{2}=kb^{2}+(2k+1)b+1} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .
Proof

Let the digits of n 2 = d 2 b 2 + d 1 b + d 0 {\displaystyle n_{2}=d_{2}b^{2}+d_{1}b+d_{0}} be d 2 = k {\displaystyle d_{2}=k} , d 1 = 2 k + 1 {\displaystyle d_{1}=2k+1} , and d 0 = 1 {\displaystyle d_{0}=1} . Then

F 3 , b ( n 2 ) = d 0 3 + d 1 3 + d 2 3 = k 3 + ( 2 k + 1 ) 3 + 1 3 = ( k 2 k ( 2 k + 1 ) + ( 2 k + 1 ) 2 ) ( k + ( 2 k + 1 ) ) + 1 = ( k 2 2 k 2 k + 4 k 2 + 4 k + 1 ) ( 3 k + 1 ) + 1 = ( 3 k 2 + 3 k + 1 ) ( 3 k + 1 ) + 1 = ( 3 k 2 + 4 k + 1 ) ( 3 k + 1 ) k ( 3 k + 1 ) + 1 = ( k + 1 ) ( 3 k + 1 ) ( 3 k + 1 ) k ( 3 k + 1 ) + 1 = k ( 3 k + 1 ) ( 3 k + 1 ) + ( 3 k + 1 ) ( 3 k + 1 ) k ( 3 k + 1 ) + 1 = k ( 3 k + 1 ) 2 + ( 2 k + 1 ) ( 3 k + 1 ) + 1 = d 2 b 2 + d 1 b + d 0 = n 2 {\displaystyle {\begin{aligned}F_{3,b}(n_{2})&=d_{0}^{3}+d_{1}^{3}+d_{2}^{3}\\&=k^{3}+(2k+1)^{3}+1^{3}\\&=(k^{2}-k(2k+1)+(2k+1)^{2})(k+(2k+1))+1\\&=(k^{2}-2k^{2}-k+4k^{2}+4k+1)(3k+1)+1\\&=(3k^{2}+3k+1)(3k+1)+1\\&=(3k^{2}+4k+1)(3k+1)-k(3k+1)+1\\&=(k+1)(3k+1)(3k+1)-k(3k+1)+1\\&=k(3k+1)(3k+1)+(3k+1)(3k+1)-k(3k+1)+1\\&=k(3k+1)^{2}+(2k+1)(3k+1)+1\\&=d_{2}b^{2}+d_{1}b+d_{0}\\&=n_{2}\end{aligned}}}

Thus n 2 {\displaystyle n_{2}} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .

  • n 3 = ( k + 1 ) b 2 + ( 2 k + 1 ) {\displaystyle n_{3}=(k+1)b^{2}+(2k+1)} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .
Proof

Let the digits of n 3 = d 2 b 2 + d 1 b + d 0 {\displaystyle n_{3}=d_{2}b^{2}+d_{1}b+d_{0}} be d 2 = k + 1 {\displaystyle d_{2}=k+1} , d 1 = 0 {\displaystyle d_{1}=0} , and d 0 = 2 k + 1 {\displaystyle d_{0}=2k+1} . Then

F 3 , b ( n 3 ) = d 0 3 + d 1 3 + d 2 3 = ( k + 1 ) 3 + 0 3 + ( 2 k + 1 ) 3 = ( ( k + 1 ) 2 ( k + 1 ) ( 2 k + 1 ) + ( 2 k + 1 ) 2 ) ( ( k + 1 ) + ( 2 k + 1 ) ) = ( ( k + 1 ) 2 + k ( 2 k + 1 ) ( 3 k + 2 ) = ( k 2 + 2 k + 1 + 2 k 2 + k ) ( 3 k + 2 ) = ( 3 k 2 + 3 k + 1 ) ( 3 k + 2 ) = ( 3 k 2 + 3 k ) ( 3 k + 2 ) + ( 3 k + 2 ) = 3 k ( k + 1 ) ( 3 k + 2 ) + ( 3 k + 2 ) = ( k + 1 ) ( ( 3 k + 1 ) 2 1 ) + ( 3 k + 2 ) = ( k + 1 ) ( 3 k + 1 ) 2 ( k + 1 ) + ( 3 k + 2 ) = ( k + 1 ) ( 3 k + 1 ) 2 + 0 ( 3 k + 1 ) + ( 2 k + 1 ) = d 2 b 2 + d 1 b + d 0 = n 3 {\displaystyle {\begin{aligned}F_{3,b}(n_{3})&=d_{0}^{3}+d_{1}^{3}+d_{2}^{3}\\&=(k+1)^{3}+0^{3}+(2k+1)^{3}\\&=((k+1)^{2}-(k+1)(2k+1)+(2k+1)^{2})((k+1)+(2k+1))\\&=((k+1)^{2}+k(2k+1)(3k+2)\\&=(k^{2}+2k+1+2k^{2}+k)(3k+2)\\&=(3k^{2}+3k+1)(3k+2)\\&=(3k^{2}+3k)(3k+2)+(3k+2)\\&=3k(k+1)(3k+2)+(3k+2)\\&=(k+1)((3k+1)^{2}-1)+(3k+2)\\&=(k+1)(3k+1)^{2}-(k+1)+(3k+2)\\&=(k+1)(3k+1)^{2}+0(3k+1)+(2k+1)\\&=d_{2}b^{2}+d_{1}b+d_{0}\\&=n_{3}\end{aligned}}}

Thus n 3 {\displaystyle n_{3}} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .

Perfect digital invariants
k {\displaystyle k} b {\displaystyle b} n 1 {\displaystyle n_{1}} n 2 {\displaystyle n_{2}} n 3 {\displaystyle n_{3}}
1 4 130 131 203
2 7 250 251 305
3 10 370 371 407
4 13 490 491 509
5 16 5B0 5B1 60B
6 19 6D0 6D1 70D
7 22 7F0 7F1 80F
8 25 8H0 8H1 90H
9 28 9J0 9J1 A0J

b = 3k + 2

Let k {\displaystyle k} be a positive integer and the number base b = 3 k + 2 {\displaystyle b=3k+2} . Then:

  • n 1 = k b 2 + ( 2 k + 1 ) {\displaystyle n_{1}=kb^{2}+(2k+1)} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .
Proof

Let the digits of n 1 = d 2 b 2 + d 1 b + d 0 {\displaystyle n_{1}=d_{2}b^{2}+d_{1}b+d_{0}} be d 2 = k {\displaystyle d_{2}=k} , d 1 = 2 k + 1 {\displaystyle d_{1}=2k+1} , and d 0 = 0 {\displaystyle d_{0}=0} . Then

F 3 , b ( n 1 ) = d 0 3 + d 1 3 + d 2 3 {\displaystyle F_{3,b}(n_{1})=d_{0}^{3}+d_{1}^{3}+d_{2}^{3}}
= k 3 + 0 3 + ( 2 k + 1 ) 3 {\displaystyle =k^{3}+0^{3}+(2k+1)^{3}}
= ( k 2 k ( 2 k + 1 ) + ( 2 k + 1 ) 2 ) ( k + ( 2 k + 1 ) ) {\displaystyle =(k^{2}-k(2k+1)+(2k+1)^{2})(k+(2k+1))}
= ( k 2 2 k 2 k + 4 k 2 + 4 k + 1 ) ( 3 k + 1 ) {\displaystyle =(k^{2}-2k^{2}-k+4k^{2}+4k+1)(3k+1)}
= ( 3 k 2 + 3 k + 1 ) ( 3 k + 1 ) {\displaystyle =(3k^{2}+3k+1)(3k+1)}
= ( 3 k 2 + 3 k + 1 ) ( 3 k + 2 ) ( 3 k 2 + 3 k + 1 ) {\displaystyle =(3k^{2}+3k+1)(3k+2)-(3k^{2}+3k+1)}
= ( 3 k 2 + 3 k + 1 ) ( 3 k + 2 ) ( 3 k 2 + 2 k + k + 1 ) {\displaystyle =(3k^{2}+3k+1)(3k+2)-(3k^{2}+2k+k+1)}
= ( 3 k 2 + 3 k + 1 ) ( 3 k + 2 ) k ( 3 k + 2 ) ( k + 1 ) {\displaystyle =(3k^{2}+3k+1)(3k+2)-k(3k+2)-(k+1)}
= ( 3 k 2 + 2 k + 1 ) ( 3 k + 2 ) ( k + 1 ) {\displaystyle =(3k^{2}+2k+1)(3k+2)-(k+1)}
= ( 3 k 2 + 2 k ) ( 3 k + 2 ) + ( 3 k + 2 ) ( k + 1 ) {\displaystyle =(3k^{2}+2k)(3k+2)+(3k+2)-(k+1)}
= k ( 3 k + 2 ) 2 + ( 2 k + 1 ) {\displaystyle =k(3k+2)^{2}+(2k+1)}
= d 2 b 2 + d 1 b + d 0 {\displaystyle =d_{2}b^{2}+d_{1}b+d_{0}}
= n 1 {\displaystyle =n_{1}}

Thus n 1 {\displaystyle n_{1}} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .

Perfect digital invariants
k {\displaystyle k} b {\displaystyle b} n 1 {\displaystyle n_{1}}
1 5 103
2 8 205
3 11 307
4 14 409
5 17 50B
6 20 60D
7 23 70F
8 26 80H
9 29 90J

b = 6k + 4

Let k {\displaystyle k} be a positive integer and the number base b = 6 k + 4 {\displaystyle b=6k+4} . Then:

  • n 4 = k b 2 + ( 3 k + 2 ) b + ( 2 k + 1 ) {\displaystyle n_{4}=kb^{2}+(3k+2)b+(2k+1)} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .
Proof

Let the digits of n 4 = d 2 b 2 + d 1 b + d 0 {\displaystyle n_{4}=d_{2}b^{2}+d_{1}b+d_{0}} be d 2 = k + 1 {\displaystyle d_{2}=k+1} , d 1 = 3 k + 2 {\displaystyle d_{1}=3k+2} , and d 0 = 2 k + 1 {\displaystyle d_{0}=2k+1} . Then

F 3 , b ( n 3 ) = d 0 3 + d 1 3 + d 2 3 {\displaystyle F_{3,b}(n_{3})=d_{0}^{3}+d_{1}^{3}+d_{2}^{3}}
= ( k ) 3 + ( 3 k + 2 ) 3 + ( 2 k + 1 ) 3 {\displaystyle =(k)^{3}+(3k+2)^{3}+(2k+1)^{3}}
= k 3 + ( ( 3 k + 2 ) 2 ( 3 k + 2 ) ( 2 k + 1 ) + ( 2 k + 1 ) 2 ) ( ( 3 k + 2 ) + ( 2 k + 1 ) ) {\displaystyle =k^{3}+((3k+2)^{2}-(3k+2)(2k+1)+(2k+1)^{2})((3k+2)+(2k+1))}
= k 3 + ( ( 3 k + 2 ) ( k + 1 ) + ( 2 k + 1 ) 2 ) ( 5 k + 3 ) {\displaystyle =k^{3}+((3k+2)(k+1)+(2k+1)^{2})(5k+3)}
= k 3 + ( 3 k 2 + 5 k + 2 + 4 k 2 + 4 k + 1 ) ( 5 k + 3 ) {\displaystyle =k^{3}+(3k^{2}+5k+2+4k^{2}+4k+1)(5k+3)}
= k 3 + ( 7 k 2 + 9 k + 3 ) ( 5 k + 3 ) {\displaystyle =k^{3}+(7k^{2}+9k+3)(5k+3)}
= k 3 + 5 k ( 7 k 2 + 9 k + 3 ) + 3 ( 7 k 2 + 9 k + 3 ) {\displaystyle =k^{3}+5k(7k^{2}+9k+3)+3(7k^{2}+9k+3)}
= k 3 + 35 k 3 + 45 k 2 + 15 k + 21 k 2 + 27 k + 9 {\displaystyle =k^{3}+35k^{3}+45k^{2}+15k+21k^{2}+27k+9}
= 36 k 3 + 66 k 2 + 42 k + 9 {\displaystyle =36k^{3}+66k^{2}+42k+9}
= ( 6 k + 4 ) ( 6 k 2 ) + 42 k 2 + 42 k + 9 {\displaystyle =(6k+4)(6k^{2})+42k^{2}+42k+9}
= ( 6 k + 4 ) ( 6 k 2 ) + ( 6 k + 4 ) ( 4 k 2 ) + 18 k 2 + 26 k + 9 {\displaystyle =(6k+4)(6k^{2})+(6k+4)(4k^{2})+18k^{2}+26k+9}
= ( 6 k + 4 ) ( 6 k 2 + 4 k ) + 18 k 2 + 26 k + 9 {\displaystyle =(6k+4)(6k^{2}+4k)+18k^{2}+26k+9}
= k ( 6 k + 4 ) 2 + ( 6 k + 4 ) ( 3 k ) + 14 k + 9 {\displaystyle =k(6k+4)^{2}+(6k+4)(3k)+14k+9}
= k ( 6 k + 4 ) 2 + ( 3 k + 2 ) ( 6 k + 4 ) + 2 k + 1 {\displaystyle =k(6k+4)^{2}+(3k+2)(6k+4)+2k+1}
= d 2 b 2 + d 1 b + d 0 {\displaystyle =d_{2}b^{2}+d_{1}b+d_{0}}
= n 4 {\displaystyle =n_{4}}

Thus n 4 {\displaystyle n_{4}} is a perfect digital invariant for F 3 , b {\displaystyle F_{3,b}} for all k {\displaystyle k} .

Perfect digital invariants
k {\displaystyle k} b {\displaystyle b} n 4 {\displaystyle n_{4}}
0 4 021
1 10 153
2 16 285
3 22 3B7
4 28 4E9

Fp,b

All numbers are represented in base b {\displaystyle b} .

p {\displaystyle p} b {\displaystyle b} Nontrivial perfect digital invariants Cycles
2 3 12, 22 2 → 11 → 2
4 {\displaystyle \varnothing } {\displaystyle \varnothing }
5 23, 33 4 → 31 → 20 → 4
6 {\displaystyle \varnothing } 5 → 41 → 25 → 45 → 105 → 42 → 32 → 21 → 5
7 13, 34, 44, 63 2 → 4 → 22 → 11 → 2

16 → 52 → 41 → 23 → 16

8 24, 64

4 → 20 → 4

5 → 31 → 12 → 5

15 → 32 → 15

9 45, 55

58 → 108 → 72 → 58

75 → 82 → 75

10 {\displaystyle \varnothing } 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20 → 4
11 56, 66

5 → 23 → 12 → 5

68 → 91 → 75 → 68

12 25, A5

5 → 21 → 5

8 → 54 → 35 → 2A → 88 → A8 → 118 → 56 → 51 → 22 → 8

18 → 55 → 42 → 18

68 → 84 → 68

13 14, 36, 67, 77, A6, C4 28 → 53 → 28

79 → A0 → 79

98 → B2 → 98

14 {\displaystyle \varnothing } 1B → 8A → BA → 11B → 8B → D3 → CA → 136 → 34 → 1B

29 → 61 → 29

15 78, 88 2 → 4 → 11 → 2

8 → 44 → 22 → 8

15 → 1B → 82 → 48 → 55 → 35 → 24 → 15

2B → 85 → 5E → EB → 162 → 2B

4E → E2 → D5 → CE → 17A → A0 → 6A → 91 → 57 → 4E

9A → C1 → 9A

D6 → DA → 12E → D6

16 {\displaystyle \varnothing } D → A9 → B5 → 92 → 55 → 32 → D
3 3 122 2 → 22 → 121 → 101 → 2
4 20, 21, 130, 131, 203, 223, 313, 332 {\displaystyle \varnothing }
5 103, 433 14 → 230 → 120 → 14
6 243, 514, 1055 13 → 44 → 332 → 142 → 201 → 13
7 12, 22, 250, 251, 305, 505

2 → 11 → 2

13 → 40 → 121 → 13

23 → 50 → 236 → 506 → 665 → 1424 → 254 → 401 → 122 → 23

51 → 240 → 132 → 51

160 → 430 → 160

161 → 431 → 161

466 → 1306 → 466

516 → 666 → 1614 → 552 → 516

8 134, 205, 463, 660, 661 662 → 670 → 1057 → 725 → 734 → 662
9 30, 31, 150, 151, 570, 571, 1388

38 → 658 → 1147 → 504 → 230 → 38

152 → 158 → 778 → 1571 → 572 → 578 → 1308 → 660 → 530 → 178 → 1151 → 152

638 → 1028 → 638

818 → 1358 → 818

10 153, 370, 371, 407

55 → 250 → 133 → 55

136 → 244 → 136

160 → 217 → 352 → 160

919 → 1459 → 919

11 32, 105, 307, 708, 966, A06, A64

3 → 25 → 111 → 3

9 → 603 → 201 → 9

A → 82A → 1162 → 196 → 790 → 895 → 1032 → 33 → 4A → 888 → 1177 → 576 → 5723 → A3 → 8793 → 1210 → A

25A → 940 → 661 → 364 → 25A

366 → 388 → 876 → 894 → A87 → 1437 → 366

49A → 1390 → 629 → 797 → 1077 → 575 → 49A

12 577, 668, A83, 11AA
13 490, 491, 509, B85 13 → 22 → 13
14 136, 409
15 C3A, D87
16 23, 40, 41, 156, 173, 208, 248, 285, 4A5, 580, 581, 60B, 64B, 8C0, 8C1, 99A, AA9, AC3, CA8, E69, EA0, EA1
4 3 {\displaystyle \varnothing }

121 → 200 → 121

122 → 1020 → 122

4 1103, 3303 3 → 1101 → 3
5 2124, 2403, 3134

1234 → 2404 → 4103 → 2323 → 1234

2324 → 2434 → 4414 → 11034 → 2324

3444 → 11344 → 4340 → 4333 → 3444

6 {\displaystyle \varnothing }
7 {\displaystyle \varnothing }
8 20, 21, 400, 401, 420, 421
9 432, 2466
5 3 1020, 1021, 2102, 10121 {\displaystyle \varnothing }
4 200

3 → 3303 → 23121 → 10311 → 3312 → 20013 → 10110 → 3

3311 → 13220 → 10310 → 3311

Extension to negative integers

Perfect digital invariants can be extended to the negative integers by use of a signed-digit representation to represent each integer.

Balanced ternary

In balanced ternary, the digits are 1, −1 and 0. This results in the following:

  • With odd powers p 1 mod 2 {\displaystyle p\equiv 1{\bmod {2}}} , F p , bal 3 {\displaystyle F_{p,{\text{bal}}3}} reduces down to digit sum iteration, as ( 1 ) p = 1 {\displaystyle (-1)^{p}=-1} , 0 p = 0 {\displaystyle 0^{p}=0} and 1 p = 1 {\displaystyle 1^{p}=1} .
  • With even powers p 0 mod 2 {\displaystyle p\equiv 0{\bmod {2}}} , F p , bal 3 {\displaystyle F_{p,{\text{bal}}3}} indicates whether the number is even or odd, as the sum of each digit will indicate divisibility by 2 if and only if the sum of digits ends in 0. As 0 p = 0 {\displaystyle 0^{p}=0} and ( 1 ) p = 1 p = 1 {\displaystyle (-1)^{p}=1^{p}=1} , for every pair of digits 1 or −1, their sum is 0 and the sum of their squares is 2.

Relation to happy numbers

A happy number n {\displaystyle n} for a given base b {\displaystyle b} and a given power p {\displaystyle p} is a preperiodic point for the perfect digital invariant function F p , b {\displaystyle F_{p,b}} such that the m {\displaystyle m} -th iteration of F p , b {\displaystyle F_{p,b}} is equal to the trivial perfect digital invariant 1 {\displaystyle 1} , and an unhappy number is one such that there exists no such m {\displaystyle m} .

Programming example

The example below implements the perfect digital invariant function described in the definition above to search for perfect digital invariants and cycles in Python. This can be used to find happy numbers.

def pdif(x: int, p: int, b: int) -> int:
    """Perfect digital invariant function."""
    total = 0
    while x > 0:
        total = total + pow(x % b, p)
        x = x // b
    return total

def pdif_cycle(x: int, p: int, b: int) -> list[int]:
    seen = []
    while x not in seen:
        seen.append(x)
        x = pdif(x, p, b)
    cycle = []
    while x not in cycle:
        cycle.append(x)
        x = pdif(x, p, b)
    return cycle

See also

References

  1. ^ a b Perfect and PluPerfect Digital Invariants Archived 2007-10-10 at the Wayback Machine by Scott Moore
  2. ^ PDIs by Harvey Heinz

External links

  • Digital Invariants
  • v
  • t
  • e
Classes of natural numbers
Of the form a × 2b ± 1
Other polynomial numbers
Recursively defined numbers
Possessing a specific set of other numbers
Expressible via specific sums
2-dimensional
centered
non-centered
3-dimensional
centered
non-centered
pyramidal
4-dimensional
non-centered
Combinatorial numbers
Divisor functions
Prime omega functions
Euler's totient function
Aliquot sequences
Primorial
Numeral system-dependent numbers
Arithmetic functions
and dynamics
Digit sum
Digit product
Coding-related
Other
P-adic numbers-related
Digit-composition related
Digit-permutation related
Divisor-related
Other
Generated via a sieve
  • Mathematics portal