Let us learn what is a special integer and how to implement special number in C programming language. This C program for Krishna Murthy Number makes use of while loop which helps in the iterative process.
It is important to know factorial program in C before proceeding with the following code. We’ve also demonstrated how to check special numbers from 1 till N in C programming.
What is a Special Number?
A number is said to be a special number if the sum of the factorial of every digit is equal to the number itself. It is, therefore, important to know how to find the factorial of a number to calculate Krishna Murthy number.
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.
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 compiled with GCC compiler on Linux Ubuntu 14.04 operating system.
Method 1: Check Special Number in C Programming 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

Method 2: C Program 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

Let us discuss more on this C program to find a special number or Krishna Murthy number in the comment section below.
Do let us know if you have any doubts or have any information to share. For information on Krishnamurthy number, check here.
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.