fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool checkprime(int x)
  5. {
  6. bool prime=true;
  7. for(int i=2; i<x; i++)
  8. {
  9. if(x%i==0)
  10. {
  11. prime=false;
  12. }
  13. }
  14. return prime;
  15. }
  16.  
  17. int main()
  18. {
  19. int a,b;
  20. cin>>a>>b;
  21. for(int i=a; i<=b; i++)
  22. {
  23. if(checkprime(i)==true)
  24. {
  25. cout<<i<<" ";
  26. }
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5456KB
stdin
3 20
stdout
3 5 7 11 13 17 19