## 2 Ways To Check Special Number in C Programming

Let us learn how to check special number in C programming language. It is important to know **Factorial Program in C** before you proceed with this code. Also Check Spe

Also, check special numbers from 1 till N in C code. This program for **Krishna Murthy Number** makes use of while loop which helps in the iterative process.

A special number is alternatively known as Krishna Murthy’s Number. Prof. Krishna Murthy is an IIT Graduate and has formulated the special number concept.

#### What is a Special Number?

An Integer is said to be a special number if the sum of the factorial of every digit is equal to the number itself.

#### Example

**145 = 1! + 4! + 5! 40585 = 4! + 0! + 5! + 8! + 5!**

**Also Read: C Program To Check Armstrong Numbers**

**Note:** This C program to find special integers or Ramanujan’s Number is developed in Linux Ubuntu operating system and compiled with GCC compiler.

#### Code To Check Special Number in C Program with While Loop

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include<stdio.h> int isSpecial(int arg) { int sum = 0, temp, count, fact; temp = arg; while(temp != 0) { fact = 1; for(count = 1; count <= temp%10; count++) { fact = fact * count; } sum = sum + fact; temp = temp/10; } if (sum == arg) { return 1; } else { return 0; } } int main() { int num, result; printf("\nEnter a Number:\t"); scanf("%d", &num); result = isSpecial(num); if(result == 1) { printf("\n%d is a Special Number\n\n", num); } else { printf("\n%d is Not a Special Number\n\n", num); } return 0; } |

If the function isSpecial() returns a value 1, then the entered number is a special integer or the Krishna Murthy number. If the function returns 0, then it is not a special integer.

#### Output

#### C Program Code To Check Special Number From 1 To N

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include<stdio.h> int isSpecial(int arg) { int sum = 0, temp, count, fact; temp = arg; while(temp != 0) { fact = 1; for(count = 1; count <= temp%10; count++) { fact = fact * count; } sum = sum + fact; temp = temp/10; } if (sum == arg) { return 1; } else { return 0; } } void main() { int limit, count; printf("\nEnter The Limit:\t"); scanf("%d", &limit); printf("\nSpecial Numbers Till %d:\n\n",limit); for(count = 1; count <= limit; count++) { if(isSpecial(count) == 1 ) { printf("%d\t",count); } } printf("\n\n"); } |

#### Output

If you get any compilation errors or if you have any doubts about this C program to find special number or Krishna Murthy number, do mention about it in the comment section.

This is amazing. Special number seems to be a combination of Armstrong Number and Factorial concepts in C Programming.

i wanna c code of ->special number which means the sum of the sum of its digits and the product of its digit is equal to the number itself .example 19 is a special number as 1+9=10 and 1*9=9 so 10+9=19.

so i want c program to find these numbers between limits.

शुकृया जनाब।

Is this also known as a Unique Integer? I guess, yes.