(C++) #include <math.h> #include <iostream> #include <conio.h> #include <time.h> #include <string> #include <cstdlib> #include <fstream> #include <stdlib.h> #include <iomanip> #include <sstream> #include <dirent.h> #include <algorithm> using namespace std; unsigned long long int reverse_num(unsigned long long int sourcenum) { unsigned long long int temp = sourcenum; unsigned long long int sum = 0; while (temp) { sum*=10; sum += temp%10; temp/=10; } return sum; } std::string IntToString ( int number ) //This Function converts ints to strings { std::ostringstream oss; oss<< number; // Return the underlying string return oss.str(); } int main() { unsigned long long int back = 0; unsigned long long int idiv = 0; float percent = 0; int count = 0; fstream out1; int digits = 0; cout << "How many digits? "; cin >> digits; string filename = "A222811_"; filename = filename + IntToString(digits); filename = filename + ".txt"; out1.open(filename.c_str(),ios::out);//open the file that contains the members of this set unsigned long long int orig = 1; for(int a = 1; a < digits; a++) { orig*=10; } cout << orig << endl; while(orig < (unsigned long long int)pow(10,digits)) { back = reverse_num(orig); idiv = orig % back; if(idiv == 0) { count++; out1 << count << " " << orig << endl; //cout << count << " " << orig << " " << back << endl; } if(orig%(unsigned long long int)pow(10,digits-2) == 0) { percent = (float)orig / pow(10,digits)*100; cout << orig << " " << percent << "% completed. Number of members so far: " << count << endl; } orig++; back = 0; } cout << endl << endl << "Total Number of members: " << count << endl; out1.close(); _getch(); }