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. In base 10, there are exactly four sum-product numbers (sequence A038369 in the OEIS): 0, 1, 135, and 144.
Definition Let n be a natural number. We define the sum-product function for base b>1, Fb:ℕ→ℕ, to be the following:
Fb(n)=(∑i=1kdi)(∏j=1kdj) where k=⌊logbn⌋+1 is the number of digits in the number in base b, and
di=nmodbi+1−nmodbibi is the value of each digit of the number. A natural number n is a sum-product number if it is a fixed point for Fb, which occurs if Fb(n)=n. The natural numbers 0 and 1 are trivial sum-product numbers for all b, and all other sum-product numbers are nontrivial sum-product numbers. For example, the number 144 in base 10 is a sum-product number, because 1+4+4=9, 1×4×4=16, and 9×16=144. A natural number n is a sociable sum-product number if it is a periodic point for Fb, where Fbp(n)=n for a positive integer p, and forms a cycle of period p. A sum-product number is a sociable sum-product number with p=1, and an amicable sum-product number is a sociable sum-product number with p=2. All natural numbers n are preperiodic points for Fb, regardless of the base. This is because for any given digit count k, the minimum possible value of n is bk−1 and the maximum possible value of n is bk−1=∑i=0k−1(b−1)i. The maximum possible digit sum is therefore k(b−1) and the maximum possible digit product is (b−1)k. Thus, the sum-product function value is Fb(n)=k(b−1)k+1. This suggests that k(b−1)k+1≥n≥bk−1, or dividing both sides by (b−1)k−1, k(b−1)2≥(bb−1)k−1. Since bb−1≥1, this means that there will be a maximum value k where (bb−1)k≤k(b−1)2, because of the exponential nature of (bb−1)k and the linearity of k(b−1)2. Beyond this value k, Fb(n)≤n always. Thus, there are a finite number of sum-product numbers, and any natural number is guaranteed to reach a periodic point or a fixed point less than bk−1, making it a preperiodic point. The number of iterations i needed for Fbi(n) to reach a fixed point is the sum-product function's persistence of n, and undefined if it never reaches a fixed point. Any integer shown to be a sum-product number in a given base must, by definition, also be a Harshad number in that base.
Extension to negative integers Sum-product numbers can be extended to the negative integers by use of a signed-digit representation to represent each integer.
Programming example The example below implements the sum-product function described in the definition above to search for sum-product numbers and cycles in Python.
See also Arithmetic dynamics Dudeney number Factorion Happy number Kaprekar's constant Kaprekar number Meertens number Narcissistic number Perfect digit-to-digit invariant Perfect digital invariant
References