Doubt in sieve code

my code is not working it says ll was not declared in the function scope and on using int it is giving a tle

hello @hazel11182

use long long in the place of ll and then try

@hazel11182 please share your code

#include using namespace std; //our range os 1000000 void prime_seive(intp) { //mark all odds as prime for(int i=3;i<=1000000;i+=2) { p[i]=1; } //seive for(long long i=3;i<=1000000; i+=2 ) { //if current number not marked, it is prime if(p[i]==1) { //mark all the multiples of i as not prime for(long long j=ii; j<=x; j+1) { //optimisation start from i^2 p[j]=0; } } } //special case p[2]=1; p[1]=p[0]=0; } int main() { // int n; //cin>>n; int p[1000005]={0}; prime_seive§; int csum[1000005]={0}; for(int i=0;i<=1000000;i++){ csum[i]=csum[i-1]+p[i]; } int q; cin>>q; while(q–){ int a,b; cin>>a>>b; cout<<csum[b]-csum[a-1]<<endl; } return 0; }

@hazel11182 please save it on and then share

In this line for(long long j=i*i; j<=1000000; j+1)
the increment line should be j = j+1 or j++

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.