The intent of this page is to collection the best program and help programmers to find good blog posts to read. Some of these blogs may not be written by Java developers, but Java developers should find it useful or interesting. Reading those blogs should be fun and often bring some fresh ideas

Sunday, February 9, 2020

C:program all Strong Numbers upto Nth place

Strong number is a special number whose sum of factorial of digits is equal to the original number.
For example: 145 is strong number. Since, 1! + 4! + 5! = 145
#include<stdio.h>
int fect(int n){
int i,res=1;
for(i=n;i>0;i--)
res*=i;
return res;
}
int isStrong_Number(int n){
int rem=0,sum=0,temp=n;
while(n){
rem=n%10;
    sum+=fect(rem);
n/=10;
}
return sum==temp;
}
void  Strong_Number(int no){
int i;
for(i=1;i<no;i++){
if(isStrong_Number(i))
printf("%d\t",i);
continue;
}
}
void main()
{
int no;
printf("Enter the Number check upto Nth Number: ");
scanf("%d",&no);
Strong_Number(no);
}

output:
Enter the Number check upto Nth Number 10000
1       2       145

No comments:

Post a Comment

If you have any doubt . Please let me know

String Operation

String Operation Using collection Framework Sorting Order  public static void sortAccending(String s) { char[] arr = s.toCharArray(); ...

Adbox