fork download
  1. #include<iostream>
  2. //#include<string.h>
  3. using namespace std;
  4. int main()
  5. {
  6. int t,m,n,i;
  7. cin>>t;
  8. while(t--)
  9. {
  10.  
  11. scanf("%d %d",&m,&n);
  12. for(i=m;i<=n;i++)
  13. {
  14. int k=0;
  15. if(i%2==0&&i!=2)
  16. continue;
  17. else
  18. {
  19. for(int j=1;j<=i/2;j++)
  20. {
  21. if(i%j==0)
  22. k++;
  23. }
  24. if(k==1||i==2)
  25. cout<<i<<endl;
  26. }
  27.  
  28.  
  29. }
  30. cout<<endl;
  31. }
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
Success #stdin #stdout 0s 4404KB
stdin
4
2 54
1 10
76 89
56 109
stdout
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53

2
3
5
7

79
83
89

59
61
67
71
73
79
83
89
97
101
103
107
109