Sum-product_number

Sum-product number

Sum-product number

Add article description


A sum-product number in a given number base 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 . In base 10, there are exactly four sum-product numbers (sequence A038369 in the OEIS): 0, 1, 135, and 144.[1]

Definition

Let be a natural number. We define the sum-product 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 sum-product number if it is a fixed point for , which occurs if . The natural numbers 0 and 1 are trivial sum-product numbers for all , 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 , , and .

A natural number is a sociable sum-product number if it is a periodic point for , where for a positive integer , and forms a cycle of period . A sum-product number is a sociable sum-product number with , and an amicable sum-product number is a sociable sum-product 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 and the maximum possible value of is The maximum possible digit sum is therefore and the maximum possible digit product is Thus, the sum-product function value is This suggests that or dividing both sides by , Since this means that there will be a maximum value where because of the exponential nature of and the linearity of Beyond this value , 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 making it a preperiodic point.

The number of iterations needed for to reach a fixed point is the sum-product function's persistence of , 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.

Sum-product numbers and cycles of Fb for specific b

All numbers are represented in base .

More information , ...

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.

def sum_product(x: int, b: int) -> int:
    """Sum-product number."""
    sum_x = 0
    product = 1
    while x > 0:
        if x % b > 0:
            sum_x = sum_x + x % b
            product = product * (x % b)
        x = x // b
    return sum_x * product

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

See also


References

  1. Sloane, N. J. A. (ed.). "Sequence A038369 (Numbers n such that n = (product of digits of n) * (sum of digits of n).)". The On-Line Encyclopedia of Integer Sequences. OEIS Foundation.

Share this article:

This article uses material from the Wikipedia article Sum-product_number, and is written by contributors. Text is available under a CC BY-SA 4.0 International License; additional terms may apply. Images, videos and audio are available under their respective licenses.