Sum of the products of same placed digits of two numbers | Function to find the sum of the products of their corresponding digits ; Loop until one of the numbers have no digits remaining ; Driver Code
def sumOfProductOfDigits ( n1 , n2 ) : NEW_LINE INDENT sum1 = 0 ; NEW_LINE while ( n1 > 0 and n2 > 0 ) : NEW_LINE INDENT sum1 += ( ( n1 % 10 ) * ( n2 % 10 ) ) ; NEW_LINE n1 = n1 // 10 ; NEW_LINE n2 = n2 // 10 ; NEW_LINE DEDENT return sum1 ; NEW_LINE DEDENT n1 = 25 ; NEW_LINE n2 = 1548 ; NEW_LINE print ( sumOfProductOfDigits ( n1 , n2 ) ) ; NEW_LINE