bsc

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

root / semester_1 / tuition-c / P054.c

P054.c (865B)


      1 /* WAP to check Krishnamurty number using user defined methods/functions. */
      2 
      3 // This code has not been compiled.
      4 // If you find any issues, please create a new issue on GitHub regarding them.
      5 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
      6 
      7 #include <stdio.h>
      8 
      9 int fact(int);
     10 int isKrishnamurty(int);
     11 
     12 int fact(int n)
     13 {
     14     int fact = 1, i;
     15     for (i = 1; i <= n; i++)
     16         fact *= i;
     17     return fact;
     18 }
     19 
     20 int isKrishnamurty(int n)
     21 {
     22     int temp = n, sum = 0;
     23     while (temp > 0)
     24     {
     25         sum += fact(temp % 10);
     26         temp /= 10;
     27     }
     28     return n == sum;
     29 }
     30 
     31 int main()
     32 {
     33     int n;
     34     printf("Enter the number : ");
     35     scanf("%d", &n);
     36     if (isKrishnamurty(n))
     37         printf("\nInput %d is a Krishnamurty Number.", n);
     38     else
     39         printf("\nInput %d is not a Krishnamurty number.", n);
     40     return 0;
     41 }
© 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