Prime Numbers between given intervals:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int Counter,NumOne,NumTwo,count,i;
scanf("%d %d",&NumOne,&NumTwo);
for (Counter = NumOne;Counter <= NumTwo;Counter++)
{
count = 0;
for ( i = 2; i <=Counter/2; i++)
{
if(Counter%i==0)
{
count++;
break;
}
}
if(count==0 && Counter!=1){
printf("%d",Counter);
}
}
return 0;
}
Complexity = O(n^2)
We can reduce this to nlog(n) comment if you need that code.