Advertisement
0Dima_0

153 4

Oct 24th, 2021
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <thread>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. bool nuberFound = false;
  9.  
  10. void getDivCount(int number) {
  11.     if (sqrt(number) != (int)sqrt(number)) {
  12.         int divCount = 0;
  13.         int lastDiv = 2;
  14.         int lookingAt = 2;
  15.         while (lookingAt < number) {
  16.             if (number % lookingAt == 0) {
  17.                 divCount++;
  18.                 lastDiv = lookingAt;
  19.                 if (divCount > 1600) break;
  20.             }
  21.             cout << "num: " << number << " | divCount: " << divCount << " | lastDiv: " << lastDiv << " | lookingAt: " << lookingAt << "\r";
  22.             lookingAt++;
  23.         }
  24.         cout << endl;
  25.         if (divCount == 1600) {
  26.             cout << "last divisor: " << lastDiv;
  27.             cout << "\n\n\nDone!";
  28.             exit(0);
  29.         }
  30.     }
  31. }
  32.  
  33. int main() {
  34.     int number = 2095133040;
  35.     vector<thread> threads;
  36.     while (!nuberFound) {
  37.         if (threads.size() > 100) {
  38.             threads[threads.size() - 1].join();
  39.             threads.pop_back();
  40.         }
  41.         threads.push_back(thread(getDivCount, number));
  42.         number++;
  43.         if (nuberFound) {
  44.             for (thread& t : threads) {
  45.                 t.detach();
  46.             }
  47.             break;
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement