Given an integer N, the task is to check whether N is a Nude number or not.
A Nude number is a number that is divisible by all of its digits (which should be nonzero).
Input: N = 672
Since, 672 is divisible by all of its three digits 6, 7 and 2. Therefore the output is Yes.
Input: N = 450
Since, 450 is not divisible by 0 (Also it gives exception). Therefore the output is No.
Approach: Extract digits from number one by one and check these two conditions:
- The digit must be non-zero, to avoid exception
- And the digit must divide the number N
When both these condition is satisfied by all digits of N, then the number is called Nude number.
Below is the implementation of the above approach:
Time complexity: O( length of N )
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if a large number is divisible by a number which is a power of 2
- Check if a number is divisible by all prime divisors of another number
- Check if the number is a Prime power number
- Check if a number with even number of digits is palindrome or not
- Program to check whether a number is Proth number or not
- Program to check whether the given number is Buzz Number or not
- Check if a number has same number of set and unset bits
- Check if a number starts with another number or not
- Check if a given number is factorial of any number
- How to check if a given number is Fibonacci number?
- Check whether the given number is Euclid Number or not
- Check if given number is Emirp Number or not
- Check Whether a number is Duck Number or not
- Check if a number is an Unusual Number or not
- Check whether a given number is an ugly number or not
- Check if a number is a Krishnamurthy Number or not
- Check if a number is a Trojan Number
- Check if a number is Flavius Number
- Check whether given number N is a Moran Number or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.