Lucian_Adrian

#374 nprime1

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