StoneHaos

cycle_1_3

Oct 15th, 2022 (edited)
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int del(int n) {
  7.     int cnt = 0;
  8.     int s = (int)sqrt(n);
  9.     for (int i = 1; i <= s; ++ i) {
  10.         if (n % i == 0) {
  11.             cnt ++;
  12.             if (n / i != i)
  13.                 cnt++;
  14.         }
  15.     }
  16.     return cnt;
  17. }
  18.  
  19. int main(void) {
  20.     int n;
  21.     cout << "n=";
  22.     cin >> n;
  23.     for (int i = 2; i <= n; ++ i)
  24.         if (del(i) == 2)
  25.             cout << i << " ";
  26.     cout << endl;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment