Advertisement
O_Egor

75

May 18th, 2022
864
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int S(int a)
  7. {
  8.     int cnt(0), sum(0);
  9.     for (int i = a / 2 + 1; i > 1; --i)
  10.     {
  11.         if (a % i == 0 && cnt < 2)
  12.         {
  13.             cnt++;
  14.             sum += i;
  15.         }
  16.     }
  17.     if (cnt == 1)
  18.         return 0;
  19.     else
  20.         return sum;
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26.     int i = 0, start = 10000000;
  27.     while (i < 5)
  28.     {
  29.         int tmp = S(start);
  30.         if (tmp < 100000 && tmp % 31 == 0 && tmp != 0)
  31.         {
  32.             cout << start << ". S(N) =" << tmp << '\n';
  33.             i++;
  34.         }
  35.         start++;
  36.     }
  37.     return 0;
  38. }
Advertisement
RAW Paste Data Copied
Advertisement