## Krishnamurthy Number

A Krishnamurthy number, also known as a strong number or a digit factorial, is a number that is equal to the sum of the factorials of its digits. More formally, a number **n** is a Krishnamurthy number if the sum of the factorials of its digits is equal to **n**.

• __let's consider the number 145__:

`1! + 4! + 5! = 1 + 24 + 120 = 145`

**Note:** Not all numbers are Krishnamurthy numbers. It's an interesting property that some numbers possess, and they are relatively rare.

__Mathematical Equation__:

Let's break down the mathematical equation that defines a Krishnamurthy number. Given a number *n* with digits `d _{1},d_{2},…,d_{k}`, the sum of the factorials of its digits is calculated as follows:

`d _{1}! + d_{2}! + … + d_{k}!`

Here, `d _{i}` represents the individual digits of the number. The factorial of a digit

`d`is the product of all positive integers less than or equal to

_{i}`d`. For example,

_{i}`4!`is equal to

`4×3×2×1=24`.

If the sum of the factorials of the digits is equal to the original number *n*, then *n* is considered a Krishnamurthy number. Mathematically, it can be expressed as:

`d _{1}! + d_{2}! + … + d_{k}! = n`

For instance, in the example of the number 145:

`1! + 4! + 5! = 1 + 24 + 120 = 145`

Since the sum of the factorials of its digits (1, 4, and 5) is equal to the number itself (145), 145 is a Krishnamurthy number. This property is an interesting mathematical concept that leads to a set of specific numbers with this factorial sum property.

• __Few examples of Krishnamurthy numbers__:

**1.** __1__:

`1! = 1`

**2.** __2__:

`2! = 2 × 1 = 2`

**3.** __145__:

`1! + 4! + 5! = 1 + 24 + 120 = 145`

**4.** __40585__:

`4! + 0! + 5! + 8! + 5! = 24 + 1 + 120 + 40320 + 120 = 40585`

**•** These numbers exhibit the property that the sum of the factorials of their digits is equal to the number itself, making them Krishnamurthy numbers.

__Programming Structure__:

Here's a simple C program to check whether a given number is a Krishnamurthy number: The program structure includes user input, function definitions for factorial calculation and Krishnamurthy number checking, and the main function for executing the overall logic.

#include ＜stdio.h> // Function to calculate the factorial of a number int factorial(int num) { if (num == 0 || num == 1) { return 1; } else { return num * factorial(num - 1); } } // Function to check if a number is a Krishnamurthy number int is_krishnamurthy(int number) { int original_number = number; int digit_sum = 0; while (number > 0) { int digit = number % 10; digit_sum += factorial(digit); number /= 10; } return digit_sum == original_number; } int main() { // Input from the user int user_input; printf("Enter a number: "); scanf("%d", &user_input); // Check if the input number is a Krishnamurthy number if (is_krishnamurthy(user_input)) { printf("%d is a Krishnamurthy number.\n", user_input); } else { printf("%d is not a Krishnamurthy number.\n", user_input); } return 0; }

Enter a number: 145 145 is a Krishnamurthy number.

#### • __Let's break down the provided C program__:

**1.** __Factorial Function__:

int factorial(int num) { if (num == 0 || num == 1) { return 1; } else { return num * factorial(num - 1); } }

**⤏** This function calculates the factorial of a given number using recursion. It returns 1 for input 0 or 1, and for other values, it multiplies the number with the factorial of *'(number - 1)'*.

**2.** __is_krishnamurthy Function__:

int is_krishnamurthy(int number) { int original_number = number; int digit_sum = 0; while (number > 0) { int digit = number % 10; digit_sum += factorial(digit); number /= 10; } return digit_sum == original_number; }

**⤏** This function checks whether a given number is a Krishnamurthy number. It iterates through each digit of the number, calculates the factorial of the digit, and adds it to *'digit_sum'*. The function returns true if *'digit_sum'* is equal to the original number, indicating that it's a Krishnamurthy number.

**3.** __Main Function__:

int main() { int user_input; printf("Enter a number: "); scanf("%d", &user_input); if (is_krishnamurthy(user_input)) { printf("%d is a Krishnamurthy number.\n", user_input); } else { printf("%d is not a Krishnamurthy number.\n", user_input); } return 0; }

**⤏** This is the main function. It takes user input for a number, calls the *'is_krishnamurthy'* function to check if it's a Krishnamurthy number, and prints the result accordingly.

In conclusion, Krishnamurthy numbers, __also known as strong numbers or digit factorials__, possess a fascinating mathematical property. These numbers are defined by the sum of the factorials of their individual digits being equal to the number itself. The exploration of Krishnamurthy numbers provides insights into both mathematical patterns and programming logic.

#### What's Next?

We've now entered the finance section on this platform, where you can enhance your financial literacy.