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
- Count number of trailing zeros in Binary representation of a number using Bitset
- Find minimum number to be divided to make a number a perfect square
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Number of ways to split a binary number such that every part is divisible by 2
- Number of times the largest perfect square number can be subtracted from N
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- 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
- Count number of ways to divide a number in 4 parts
- Build Lowest Number by Removing n digits from a given number
- Find the smallest number whose digits multiply to a given number n
- Super Ugly Number (Number whose prime factors are in given set)
- Querying maximum number of divisors that a number in a given range has
- Program to calculate the number of odd days in given number of years
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