Advertisement
Josif_tepe

Untitled

Apr 13th, 2025
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. void print(int x) {
  6.     if(x > 100) {
  7.         return;
  8.     }
  9.    
  10.     bool prost = true;
  11.     for(int i = 2; i < x; i++) {
  12.         if(x % i == 0) {
  13.             prost = false;
  14.             break;
  15.         }
  16.     }
  17.     if(prost and x != 1) {
  18.         cout << x << " ";
  19.     }
  20.     print(x + 1);
  21. }
  22. int main() {
  23.     print(1);
  24.    
  25.     return 0;
  26. }
  27. // print(1) --> print(2) | cout << 1;
  28. // print(2) --> print(3) | cout << 2;
  29. // print(3) --> print(4) | cout << 3;
  30. // print(4) --> print(5) | cout << 4;
  31. // print(5) --> print(6) | cout << 5;
  32. // print(6)
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement