top of page
Wave
Cactus%20Plant_edited.jpg

KRISHNAMURTHY NUMBER

#include<stdio.h>
int main()
{
    int n,z,r,s,i,f;
    printf("Enter the number: ");
    scanf("%d",&n);
    s=0;
    z=n;
    while(z!=0)    
    {
        r=z%10;
        f=1;
        z=z/10;
        for(i=1;i<=r;i++)
        {
            f=f*i;
        }
        s=s+f;
    }
    if(n==s)
        printf("\nThe entered number is a krishnamurti number\n");
    else
        printf("\nThe entered number is not a krishnamurti number\n");
    return 1;
}

Cactus%20Plant_edited.jpg

KRISHNAMURTHY NUMBER RANGE

#include<stdio.h>
int main()
{
    int n,z,r,s,a,b,i,f;
    printf("Enter the lower limit of the range: ");
    scanf("%d",&a);
    printf("\nEnter the upper limit of the range: ");
    scanf("%d",&b);
    printf("\nKrishnamurty numbers are: \n\n");
    for(n=a;n<=b;n++)
    {
        s=0;
        z=n;
        while(z!=0)    
        {
            r=z%10;
            f=1;
            z=z/10;
            for(i=1;i<=r;i++)
            {
                  f=f*i;
            }
               s=s+f;
        }
        if(n==s)
        {
            printf("%d ",n);
        }
    }
    return 1;
}

Subscribe Form

Thanks for submitting!

  • Facebook
  • YouTube
  • Instagram
  • Twitter

©2020 by Abhisek Midya ( A18 )

bottom of page