Table of Contents
Introduction
The task is to check whether all the digits of number N divides it.
Program
def check(ip_num, i) : return (i != 0 and ip_num % i == 0) def checkInput(ip_num) : val = ip_num while (val > 0) : i = val % 10 if ((check(ip_num, i)) == False) : return False val = val // 10 return True ip_num = int(input("Enter the number: ")) if (checkInput(ip_num)) : print("The number is divisible by its all digits!") else : print("The number is not divisible by its all digits!" )
Output
Explanation
In the above python code, we iterate over all the digits of given number and check D!=0 and 124%D == 0 where D = {1, 2, 4}.
0 Comments