#include using namespace std; bool countdiv500(int x); int main() { for(int i = 1; ;i++) { int tn = (i * (i + 1)) / 2; cout << "\n" << tn << " -- " << i; if(countdiv500(tn)) { cout << "\nRequired number: " << tn; break; } } cout << "\n"; return 0; } bool countdiv500(int x) { int count = 0, i = 1; while(i != x) { if(x % i == 0) { count++; } if(count == 500) { return 1; break; } i++; } return 0; }