Given a number ‘n’, check whether it is a hoax number or not.
A Hoax Number is defined as a composite number, whose sum of digits is equal to the sum of digits of its distinct prime factors. It may be noted here that, 1 is not considered a prime number, hence it is not included in the sum of digits of distinct prime factors.
Input : 22 Output : A Hoax Number Explanation : The distinct prime factors of 22 are 2 and 11. The sum of their digits are 4, i.e 2 + 1 + 1 and sum of digits of 22 is also 4. Input : 84 Output : A Hoax Number Explanation : The distinct prime factors of 84 are 2, 3 and 7. The sum of their digits are 12, i.e 2 + 3 + 4 and sum of digits of 84 is also 12. Input : 19 Output : Not a Hoax Number Explanation : By definition, a hoax number is a composite number.
The definition of Hoax numbers bears close resemblance with the definition of Smith Numbers. In fact, some of the Hoax numbers are also Smith numbers. It is apparent that those hoax numbers that do not have repeated factors in their prime decomposition, i.e square free number are also eligible Smith numbers.
1) First generate all distinct prime factors of the number ‘n’.
2) If the ‘n’ is not a prime number, find the sum of digits of the factors obtained in step 1.
3) Find the sum of digits of ‘n’.
4) Check if the sums obtained in steps 2 and 3 are equal or not.
5) If the sums are equal, ‘n’ is a hoax number.
A Hoax Number
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.
- Number of factors of very large number N modulo M where M is any prime number
- Find minimum number to be divided to make a number a perfect square
- How to check if a given number is Fibonacci number?
- Find the smallest number whose digits multiply to a given number n
- Find n'th number in a number system with only 3 and 4
- Build Lowest Number by Removing n digits from a given number
- Minimum number of squares whose sum equals to given number n
- Count number of subsets of a set with GCD equal to a given number
- Count number of ways to divide a number in 4 parts
- Querying maximum number of divisors that a number in a given range has
- Check if a number is a power of another number
- Find the Largest number with given number of digits and sum of digits
- Finding number of digits in n'th Fibonacci number
- Smallest number by rearranging digits of a given number
- Super Ugly Number (Number whose prime factors are in given set)
- Number with maximum number of prime factors
- Convert a number m to n using minimum number of given operations
- Determine whether a given number is a Hyperperfect Number
- Find count of digits in a number that divide the number
- Convert a binary number to hexadecimal number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.
Improved By : manishshaw1