Check whether product of digits at even places is divisible by sum of digits at odd place of a number | Below function checks whether product of digits at even places is divisible by sum of digits at odd places ; Converting integer to string ; Traveersing the string ; Driver code
def productSumDivisible ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE product = 1 NEW_LINE num = str ( n ) NEW_LINE for i in range ( len ( num ) ) : NEW_LINE INDENT if ( i % 2 != 0 ) : NEW_LINE INDENT product = product * int ( num [ i ] ) NEW_LINE DEDENT else : NEW_LINE INDENT sum = sum + int ( num [ i ] ) NEW_LINE DEDENT DEDENT if ( product % sum == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 1234 NEW_LINE if ( productSumDivisible ( n ) ) : NEW_LINE INDENT print ( " TRUE " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " FALSE " ) NEW_LINE DEDENT DEDENT