bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / tuition-c / APC-PRAC-036.c

APC-PRAC-036.c (939B)


      1 /* Check krishnamurty number. */
      2 /* Auhtor: Amit Dutta, Date: 20-11-2025 */
      3 
      4 // This code has not been compiled.
      5 // If you find any issues, please create a new issue on GitHub regarding them.
      6 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
      7 
      8 #include <stdio.h>
      9 
     10 int factorial(int);
     11 int checkKrishnamurty(int);
     12 
     13 int factorial(int n)
     14 {
     15     int i, fact = 1;
     16     for (i = 1; i <= n; i++)
     17         fact *= i;
     18     return fact;
     19 }
     20 
     21 int checkKrishnamurty(int n)
     22 {
     23     int temp1 = n, temp2 = 0;
     24     while (temp1 > 0)
     25     {
     26         temp2 += factorial(temp1 % 10);
     27         temp1 /= 10;
     28     }
     29     if (temp2 == n)
     30         return 1;
     31     else
     32         return 0;
     33 }
     34 
     35 int main()
     36 {
     37     int n;
     38     printf("Enter the number: ");
     39     scanf("%d", &n);
     40     if (checkKrishnamurty(n))
     41         printf("\nInput %d is a Krishnamurty number.", n);
     42     else
     43         printf("\ninput %d is not a Krishnamurty number.", n);
     44     return 0;
     45 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror