fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char* argv[])
  7. {
  8. long long a, b;
  9. cin >> a >> b;
  10. for(long long n = max(2LL, a); n <= b; n++)
  11. {
  12. int sqrt_n = (int)(0.1+sqrt((double)n));
  13. bool prime = true;
  14. for(int p=2; p<=sqrt_n; p++)
  15. {
  16. if(n%p==0)
  17. {
  18. prime = false;
  19. break;
  20. }
  21. }
  22. if(prime)
  23. cout << n << endl;
  24. }
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.05s 4372KB
stdin
999999999847 999999999947
stdout
999999999847
999999999857
999999999863
999999999877
999999999899
999999999937