TwITe

Untitled

Sep 14th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. bool is_current_divisor_simple(int divisor) {
  2.     for (int i = 2; i <= sqrt(divisor); i++) {
  3.         if (divisor % i == 0) {
  4.             return false;
  5.         }
  6.     }
  7. }
  8.  
  9. void task5() {
  10.     int n;
  11.     cin >> n;
  12.     for (int divisor = 2; divisor < n; divisor++) {
  13.         if (n % divisor == 0) {
  14.             if (is_current_divisor_simple(divisor)) {
  15.                 cout << divisor << " ";
  16.             }
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment