Given an integer N, check whether the given number is a Moran Number or not. Moran numbers are a subset of Harshad numbers.
A number N is a Moran number if N divided by the sum of its digits gives a prime number. For example some Moran numbers are 18, 21, 27, 42, 45 and so on.
Input: N = 34
34 is not a moran number because it is not completely divisible 7 (sum of its digits).
Input: N = 21
21 is a moran number because 21 divided by the sum of its digits gives a prime number.
Approach: To solve the problem mentioned above we have to find the sum of digits of that number. Then find the quotient by dividing the number by the sum of its digits and check if the quotient is a prime then the given number is a Moran Number.
Below is the implementation of the above approach:
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 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 whether all the rotations of a given number is greater than or equal to the given number or not
- Program to check whether a number is Proth number or not
- Check if a number with even number of digits is palindrome or not
- Check if the number is a Prime power number
- Check whether a given number N is a Nude Number or not
- Check if a number is an Unusual Number or not
- Check if a number is a power of another number
- Check if a number is Flavius Number
- Check if a number is a Krishnamurthy Number or not
- Check whether a number is Non-hypotenuse number
- Check if a number is a Mystery Number
- Check if a number is an Achilles number or not
- Check if a number is a Trojan Number
- Check if a number is Triperfect Number
- How to check if a given number is Fibonacci number?
- Check if a given number is factorial of any number
- Check Whether a number is Duck Number or not
- Check if a number starts with another 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.