Given a number N, the task is to check whether it is fascinating or not.
Fascinating Number: When a number( 3 digits or more ) is multiplied by 2 and 3, and when both these products are concatenated with the original number, then it results in all digits from 1 to 9 present exactly once. There could be any number of zeros and are ignored.
After multiplication with 2 and 3, and concatenating with original number, resultant number is 192384576 which contains all digits from 1 to 9.
After multiplication with 2 and 3, and concatenating with original number, the resultant number is 85317062559. In this, number 4 is missing and the number 5 has appeared multiple times.
- Check if the given number has three digits or more. If not, print No.
- Else, Multiply the given number with 2 and 3.
- Concatenate these products with the given number to form a string.
- Traverse this string, keep the frequency count of the digits.
- Print No if any digit is missing or has appeared multiple times.
- Else, print Yes.
Below is the implementation of above approach:
- 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
- Count number of trailing zeros in Binary representation of a number using Bitset
- Number of times the largest perfect square number can be subtracted from N
- Find a number which give minimum sum when XOR with every number of array of integers
- Given number of matches played, find number of teams in tournament
- Maximum number of contiguous array elements with same number of set bits
- Find the number of jumps to reach X in the number line from zero
- Count the number of operations required to reduce the given number
- Count Number of animals in a zoo from given number of head and legs
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Find the smallest number whose digits multiply to a given number n
- Querying maximum number of divisors that a number in a given range has
- Find the number of integers x in range (1,N) for which x and x+1 have same number of divisors
- Find the total number of composite factor for a given 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.