- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program for Check if all digits of a number divide it
In this article, we will learn about the solution and approach to solve the given problem statement.
Problem statement −Given a number n, find whether all digits of n divide it or not.
Here we will be checking that there is no 0 in the given number because this will give divide by zero exception and hence we must return no as an answer
Otherwise, we must check whether all digits are able to divide the number by using a temporary variable flag which allows declaring a check condition.
Now let’s have a look at the implementation −
n=int(input()) flag=1 for i in str(n): if int(i)!=0 and n%int(i)==0: flag=1 else: flag=0 if(flag==1): print("Yes") else: print("No")
All the variables are declared in global scope as shown in the image below
In this article, we learnt about the approach to Check if all digits of a number divide it.
- Check if all digits of a number divide it in Python
- C Program to Check if all digits of a number divide it
- PHP program to check if all digits of a number divide it
- Java Program to check if all digits of a number divide it
- Check if the frequency of all the digits in a number is same in Python
- C++ Program to check if a given number is Lucky (all digits are different)
- Check if all bits of a number are set in Python
- Python Program for How to check if a given number is a Fibonacci number?
- C Program to check if a number is divisible by sum of its digits
- C Program to check if a number is divisible by any of its digits
- Java Program for check if a given number is Fibonacci number?
- Python Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Python - Check if a List contain particular digits
- Python Program to Check if a Number is a Perfect Number