You are viewing a single comment's thread. Return to all comments →
int solve(int n) { int s=0; int i=2; int j=n; int r=0; while(j!=0){ r=r+j%10; j=j/10; } while(n>1){ if(n%i==0){ n=n/i; int k=i; while(k!=0){ s=s+k%10; k=k/10; } } else i++; } if(r==s) return 1; else return 0;
Identify Smith Numbers
You are viewing a single comment's thread. Return to all comments →
int solve(int n) { int s=0; int i=2; int j=n; int r=0; while(j!=0){ r=r+j%10; j=j/10; } while(n>1){ if(n%i==0){ n=n/i; int k=i; while(k!=0){ s=s+k%10; k=k/10; } } else i++; } if(r==s) return 1; else return 0;