Guest User

Untitled

a guest
Dec 9th, 2019
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #include <chrono>
  3. using namespace std;
  4. using namespace std::chrono;
  5.  
  6. bool checa_primos(int n)
  7. {
  8. for (int i = 3 ; i <= sqrt(n); i += 2)
  9. {
  10. if(n % i == 0)
  11. {
  12. return false;
  13. }
  14. }
  15. return true;
  16. }
  17. void solve ()
  18. {
  19. int i = 3 ;
  20. auto start = high_resolution_clock::now();
  21. auto stop = high_resolution_clock::now();
  22. auto duration = duration_cast<seconds>(stop - start);
  23.  
  24. while(duration.count() < 60)
  25. {
  26.  
  27. if(checa_primos(i))
  28. {
  29. cout << i << endl ;
  30. }
  31.  
  32. i++;
  33. stop = high_resolution_clock::now();
  34. duration = duration_cast<seconds>(stop - start);
  35. }
  36. }
  37. int main ()
  38. {
  39. printf("2\n");
  40. solve();
  41. return 0 ;
  42. }
RAW Paste Data