#include long long unsigned int rev(long long unsigned int); int contains(long long unsigned int,int); int reversible(long long unsigned int); int main() { long long unsigned int i,r,s,count,max,min; min = 1; max = 1000000000; count = 0; for (i = min; i < max; i++) { r = rev(i); if (r != 0) { s = r + i; if (reversible(s)) { count++; } } if ((i % 100000000) == 0) { printf("On %llu: ",i); printf("%llu\n",count); } } printf("Total: %llu\n",count); } int reversible(long long unsigned int x) { int reversible = 1; while (x > 0 && reversible) { reversible = (x % 2); x /= 10; } return reversible; } int contains(long long unsigned int x,int i) { long long unsigned int r = 0; int found = 0; while (x > 0 && ! found) { found = (x % 10 == i); x /= 10; } return found; } long long unsigned int rev(long long unsigned int x) { long long unsigned int r = 0; if (x % 10) { while (x > 0) { r = (r * 10) + (x % 10); x /= 10; } } return r; }