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 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
- Number of times a number can be replaced by the sum of its digits until it only contains one digit
- Count number of digits after decimal on dividing a number
- Find maximum number that can be formed using digits of a given number
- Querying maximum number of divisors that a number in a given range has
- Number of digits to be removed to make a number divisible by 3
- Represent a number as a sum of maximum possible number of Prime Numbers
- Count Number of animals in a zoo from given number of head and legs
- Count number of ways to divide a number in 4 parts
- Program to Convert Octal Number to Binary Number
- Super Ugly Number (Number whose prime factors are in given set)
- Build Lowest Number by Removing n digits from a given number
- Queries on sum of odd number digit sums of all the factors of a 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