Check if all digits of a number divide it in Python

Share on facebook
Share on twitter
Share on pinterest

In this Python program, we will check if all digits of a number divide it or not.

Python Program to check if all digits of a number divide it

def checkDiv(n, digit) : 
return (digit != 0 and n % digit == 0) 
def allDigitsDivide( n) : 
x = n 
while (x > 0) : 
digit = n % 10
if ((checkDivis(n, digit)) == False) : 
return False
x = x // 10
return True
n = 128
if (allDigitsDivide(n)) : 
print("Yes") 
else : 
print("No" ) 

Output: Yes

Subscribe to our Newsletter

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Share this post with your friends

Share on facebook
Share on google
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *