bsc

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

APC-PRAC-036.c (1130B)


      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 /* Check krishnamurty number. */
      9 /* Auhtor: Amit Dutta, Date: 20-11-2025 */
     10 
     11 // This code has not been compiled.
     12 // If you find any issues, please create a new issue on GitHub regarding them.
     13 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
     14 
     15 #include <stdio.h>
     16 
     17 int factorial(int);
     18 int checkKrishnamurty(int);
     19 
     20 int factorial(int n)
     21 {
     22     int i, fact = 1;
     23     for (i = 1; i <= n; i++)
     24         fact *= i;
     25     return fact;
     26 }
     27 
     28 int checkKrishnamurty(int n)
     29 {
     30     int temp1 = n, temp2 = 0;
     31     while (temp1 > 0)
     32     {
     33         temp2 += factorial(temp1 % 10);
     34         temp1 /= 10;
     35     }
     36     if (temp2 == n)
     37         return 1;
     38     else
     39         return 0;
     40 }
     41 
     42 int main()
     43 {
     44     int n;
     45     printf("Enter the number: ");
     46     scanf("%d", &n);
     47     if (checkKrishnamurty(n))
     48         printf("\nInput %d is a Krishnamurty number.", n);
     49     else
     50         printf("\ninput %d is not a Krishnamurty number.", n);
     51     return 0;
     52 }
© 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