Description
Input
Output
Sample Output
1 3 5 7 9 20 31 42 53 64 | | <-- a lot more numbers | 9903 9914 9925 9927 9938 9949 9960 9971 9982 9993
#include <iostream> #include <cmath> using namespace std; int main() { int i , n , sum ; int a[10001] ; for(i=1;i<=10000;i++) a[i] = i ; for( i = 1 ; i <= 10000 ; i++ ) { n = i ; sum = n ; while( n != 0 ) { sum += n % 10 ; n /= 10 ; } //cout<<sum<<endl; if( a[sum] == sum && sum <= 10000 ) a[sum] = -1 ; } for(i=1;i<=10000;i++) if( a[i] == i ) cout<<a[i]<<endl; return 0; }