Problem: Write a C program to check whether the given number is a Fascinating number or not.

A Fascinating number is a number which when concatenated with its multiple of 2 and 3 together gives a number that contains all digits from 1 to 9 exactly once.

For example: 192.

The algorithm to check the Fascinating number in C is as follows:

  1. Input a number.
  2. Compute its multiple of 2 and 3 respectively.
  3. Concatenate the input number, it’s multiple of 2 and 3 together.
  4. Count the occurrence of each digit from 1 to 9 in the resulting number.
  5. If any count is not 1, then the input number is not a Fascinating number otherwise, it is.

Here is the C program which implements the above algorithm to check Fascinating number:


Enter a number
Fascinating Number

Enter a number
Non Fascinating Number

In the above program, to count the frequency of each digit in the concatenated number, we have uses an array of size 10 i.e. count[10], in which each index represents the digit and its corresponding value as its count.

Note: Digit 0 is not considered while checking Fascinating number.

In this tutorial, we learned What a Fascinating number is and how to check whether the given number is Fascinating or not in the C programming language.

This Post Has 2 Comments

  1. Srikant kadgi

    Send full Program.

    1. Adarsh Kumar

      Program does not work for you?

Leave a Reply

13 − one =