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
- Count number of trailing zeros in Binary representation of a number using Bitset
- Count number of triplets with product equal to given number with duplicates allowed
- Find minimum number to be divided to make a number a perfect square
- Number which has the maximum number of distinct prime factors in the range M to N
- Given number of matches played, find number of teams in tournament
- Represent a number as a sum of maximum possible number of Prime Numbers
- Count number of digits after decimal on dividing a number
- Minimum number of given powers of 2 required to represent a number
- Number of times a number can be replaced by the sum of its digits until it only contains one digit
- Find the largest good number in the divisors of given number N
- Print a number strictly less than a given number such that all its digits are distinct.
- Super Ugly Number (Number whose prime factors are in given set)
- Find the maximum number of composite summands of a number
- Find maximum number that can be formed using digits of a given number
- Check if a number is divisible by all prime divisors of another 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 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.
Improved By : manishshaw1