Lucian_Adrian

#434 PerechiPrime

Oct 26th, 2021
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n;
  6. cin >> n;
  7. int x = 3;
  8. while(n>0)
  9. {
  10. int y = x+2;
  11. int prim = 1;
  12.  
  13. for(int d = 3 ; d*d <= y && prim ; d += 2)
  14. if(x % d == 0 || y % d == 0)
  15. prim = 0;
  16. if(prim)
  17. cout << x << " " << y << "
  18. ", n --;
  19. x += 2;
  20. }
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment