- Full Information About Artificial Intelligence | What is AI?
- Most Common Important 70+ Shortcut Keyboard Keys
- Stars Square Pattern
- Fascinating Number or Not in C and CPP
- Implement queue using linked list c program
- Calculate the GCD | Euclidean algorithm | c and cpp programming language
- Linear search in c | Algorithm of Linear search | c programming
- A C program for checking whether a given line is a comment
- C program to convert decimal to binary without array
- Voting program in C language using switch case
- C program to check eligible for vote
- Insertion and deletion in double linked list in c program
- File read in C | File Handling | How to read File
- C program to replace vowels with special characters
- Call by Reference in C programming language
- Function call by value in c programming language
- Program to print a message without using semicolon in c programming
- User login system in c programming language
- How to make swastik in c and cpp programming language
- Print numbers from 1 to 100 using while loop c and cpp program
- Simple Macro Substitution(#define) in c and cpp programming language
- Insertion and Deletion of all operation at singly Linked list in c programming langauge
- Write a program to count the digit in a number
- Program to calculate the power of given numbers by user in c and cpp
- Sum of digit calculate program
- Write a program to reverse a number
- Floyd Triangle | Programs | Algorithm
- Program to check whether number is Disarium Number
- Sunny Number in programming
- Happy Number | with Example and Programs
- Display Name of the month by accepting digit of the month | c programming
- Spy Number | c programming
- 9 basic program in cpp programming language
- Automorphic number | c programming language
- C programming restaurant menu code lapmos
- Neon Number c programming language
- Strong Number in C programming What is Strong Number
- Leap Year | Leap year program in c
- Pascal Triangle C programming
- Check Palindrome Number in c
- Print Fibonacci Series in c
- Swap two number without using third variable c programming langauge
- Swap two number c programming
- Largest Number c programming language
- Prime number program in c
- What is the mean by Software Engineering?

**Three-digit number is called fascinating number** when it is concatenated with two multiplications **(n * 2)*** and three multiplications ***(n * 3)** so that all the digit from **1 to 9 are present exactly once**.

* **NOTE:* No matter how many zeros there are, they will be ignored. All the other digits need to occur only once.

For Example:

273 is a **Fascinating Number**.

273 * 1 = 273

273 * 2 = 546

273 * 3 = 819

We get the final number 273546819 by concatenating all the number. In this number, all digits from 1 to 9 appear exactly once.

```
#include<stdio.h>
int isFascinating(int n);
int main(){
int n;
printf("Enter 3 digit number : ");
scanf("%d", &n);
if(isFascinating(n)){
printf("Given number is Fascinating.");
}else{
printf("Given Number is not Fascinating.");
}
return 0;
}
int isFascinating(int n){
int n2 = n * 2;
int n3 = n * 3;
int freq[11] = {0}; // to count freq. of the one digits
while(n!=0){
freq[n%10]++;
n = n / 10;
}
while(n2 != 0){
freq[n2 % 10]++;
n2 = n2 / 10;
}
while(n3 != 0){
freq[n3 % 10]++;
n3 = n3 / 10;
}
// If the number is fascinating then the freq array must have exactly 1 in all the indexes from 1 to 9;
for(int i = 1; i <= 9; i++){
if(freq[i] != 1){
return 0; // Not Fascinating No.
}
}
return 1; // Fascinating No.
}
```

```
#include<iostream>
using namespace std;
int isFascinating(int n);
int main(){
int n;
cout<<"Enter 3 digit number : ";
cin>>n;
if(isFascinating(n)){
cout<<"Given number is Fascinating.";
}else{
cout<<"Given Number is not Fascinating.";
}
return 0;
}
int isFascinating(int n){
int n2 = n * 2;
int n3 = n * 3;
int freq[11] = {0}; // to count freq. of the one digits
while(n!=0){
freq[n%10]++;
n = n / 10;
}
while(n2 != 0){
freq[n2 % 10]++;
n2 = n2 / 10;
}
while(n3 != 0){
freq[n3 % 10]++;
n3 = n3 / 10;
}
// If the number is fascinating then the freq array must have exactly 1 in all the indexes from 1 to 9;
for(int i = 1; i <= 9; i++){
if(freq[i] != 1){
return 0; // Not Fascinating No.
}
}
return 1; // Fascinating No.
}
```

ðŸ–¤ 0

Buy me coffee â˜•

## Comments

Oops!