Sir, my code is showing the wrong output. Could you tell me what changes are required? Prime Sieve is correctly calculated but the problem lies in calculating the cumulative sum array.
PrimeVists. Help needed in debugging
Utkarsh rather than the approach you are following in your code .you can use another approach in which firstly you will call your primeseive function in your main function…and then you will take a counter variable initialised to 0 and further you will use two values a and b …in between you need to count the no of prime nos and then increment it’s value and finally print it. The code snippet is as follows :
int cnt=0;
cin>>a>>b;
for(long long int i=a;i<=b;i++)
{
if(p[i]==1)
{
cnt=cnt+1;
}
}
cout<<cnt<<endl;