Check if the sum of digits of number is divisible by all of its digits | Python implementation of above approach ; Converting integer to string ; Initialising sum to 0 ; Traversing through the string ; Converting character to int ; Comparing number and sum Traversing again ; Check if any digit is not dividing the sum ; Return false ; If any value is not returned then all the digits are dividing the sum SO return true ; Driver Code ; passing this number to get result function
def getResult ( n ) : NEW_LINE INDENT st = str ( n ) NEW_LINE sum = 0 NEW_LINE length = len ( st ) NEW_LINE for i in st : NEW_LINE INDENT sum = sum + int ( i ) NEW_LINE DEDENT for i in st : NEW_LINE INDENT if ( sum % int ( i ) != 0 ) : NEW_LINE INDENT return ' No ' NEW_LINE DEDENT DEDENT return ' Yes ' NEW_LINE DEDENT n = 123 NEW_LINE print ( getResult ( n ) ) NEW_LINE