Here's a function that takes no arguments and returns two 4-digit numbers whose difference is equal to the difference of their digits' product.
main.py347 chars13 lines
The function digits_product
takes an integer as input and returns the product of its digits. The find_numbers
function then loops through all pairs of 4-digit numbers, checks if their difference is equal to the difference of their digits' product, and returns the pair of numbers if found. Note that we start the inner loop at num1+1
to avoid considering pairs of identical numbers.
gistlibby LogSnag