bsc

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

P054.c (1056B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 12 Dec 2025
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* WAP to check Krishnamurty number using user defined methods/functions. */
      9 
     10 // This code has not been compiled.
     11 // If you find any issues, please create a new issue on GitHub regarding them.
     12 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
     13 
     14 #include <stdio.h>
     15 
     16 int fact(int);
     17 int isKrishnamurty(int);
     18 
     19 int fact(int n)
     20 {
     21     int fact = 1, i;
     22     for (i = 1; i <= n; i++)
     23         fact *= i;
     24     return fact;
     25 }
     26 
     27 int isKrishnamurty(int n)
     28 {
     29     int temp = n, sum = 0;
     30     while (temp > 0)
     31     {
     32         sum += fact(temp % 10);
     33         temp /= 10;
     34     }
     35     return n == sum;
     36 }
     37 
     38 int main()
     39 {
     40     int n;
     41     printf("Enter the number : ");
     42     scanf("%d", &n);
     43     if (isKrishnamurty(n))
     44         printf("\nInput %d is a Krishnamurty Number.", n);
     45     else
     46         printf("\nInput %d is not a Krishnamurty number.", n);
     47     return 0;
     48 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror