0

Why does it only give two answers for any inputs?

#include<stdio.h> #include<math.h> int fact(int); void main() { int n,k,x,sum,a,b,i; printf("enter any numbers:"); scanf("%d%d",&a,&b); for(i=a;i<=b;i++) { sum=0; k=i; n=i; while(n>0) { x=n%10; sum=sum+fact(x); n=n/10; } if(sum==k) printf(" %d",sum); } } int fact(int y) { if(y==1) return 1; else return (y*fact(y-1)); }

1st Sep 2020, 10:24 AM
Prashant Pandey
Prashant Pandey - avatar
7 Respostas
0
Prashant Pandey am getting 145 also.. But make this change in fact function if condition if(y<=1) In that range only 1, 2, 145 are strong numbers......
1st Sep 2020, 12:42 PM
Jayakrishna 🇼🇳
0
You can find answer if you know purpose of the program.. What is the purpose of program..? What are your inputs and output..? Prashant Pandey tried.....
1st Sep 2020, 11:55 AM
Jayakrishna 🇼🇳
0
I want to know strong numbers between two numbers
1st Sep 2020, 12:02 PM
Prashant Pandey
Prashant Pandey - avatar
0
What are your inputs? Outputs? It only displays Number == factorial(sum of its digits of Number )
1st Sep 2020, 12:27 PM
Jayakrishna 🇼🇳
0
Inputs are 1 and 500 and it only outputs 1 and 2
1st Sep 2020, 12:28 PM
Prashant Pandey
Prashant Pandey - avatar
0
Okay thanks
1st Sep 2020, 12:43 PM
Prashant Pandey
Prashant Pandey - avatar
0
You're welcome..
1st Sep 2020, 12:43 PM
Jayakrishna 🇼🇳