Hey,
It is fully working Prime Generator but judge says that it exceed time limit. What should i do with this to make it faster? Any advices, tips for my code?
Here is my code :
include
using namespace std;
int main()
{
int t = 5;
int m, n;
int number;
int howMany = 0;
cin >> t;
while (t<=10 && t >= 1)
{
cin >> m >> n;
if ((1 <= m) && (m <= n) && (n <= 100000000) && ((n-m)<=100000))
{
number = m;
while (number <= n)
{
howMany = 0;
for (int i = 1; i <= number; i++)
{
if (number % i == 0) howMany++;
if (howMany >= 3)
break;
}
if (howMany == 2 && howMany != 3)
cout << number << endl;
number++;
}
}
t--;
cout << endl;
}
return 0;
}
Thanks