Advertisement
maxim_shlyahtin

953

Nov 23rd, 2021
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include<vector>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int c = 0, count_simp = 0, sum = 0;
  10.     for (int i = 499999; i > 0; i--)
  11.     {
  12.         for (int j = 2; j < i; j++)
  13.         {
  14.             if (i % j == 0)
  15.             {
  16.                 for (int k = 1; k < j; k++)
  17.                 {
  18.                     if (j % k == 0)
  19.                     {
  20.                         count_simp++;
  21.                     }
  22.                 }
  23.             }
  24.             if (count_simp == 1)
  25.             {
  26.                 sum += j;
  27.             }
  28.             count_simp = 0;
  29.         }
  30.         if (sum % 10 == 0 && sum > 0)
  31.         {
  32.             cout << i << " " << sum << endl;
  33.             c++;
  34.         }
  35.         if (c == 7)
  36.         {
  37.             break;
  38.         }
  39.         sum = 0;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement