Check if the sum of digits of number is divisible by all of its digits | Function that returns true if all the digits of n divide the sum of the digits of n ; Store a copy of the original number ; Find the sum of the digits of n ; Restore the original value ; Check if all the digits divide the calculated sum ; If current digit doesn 't  divide the sum ; Driver code
def isDivisible ( n ) : NEW_LINE INDENT temp = n NEW_LINE sum = 0 NEW_LINE while ( n ) : NEW_LINE INDENT digit = n % 10 NEW_LINE sum += digit NEW_LINE n //= 10 NEW_LINE DEDENT n = temp NEW_LINE while ( n ) : NEW_LINE INDENT digit = n % 10 NEW_LINE if ( sum % digit != 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT n //= 10 ; NEW_LINE DEDENT return True NEW_LINE DEDENT n = 123 NEW_LINE if ( isDivisible ( n ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT