I have used the same code in prime sieve but it is showing compilation error . Please solve this.
Error in Prime Sieve question
#include #define ll long long using namespace std; // Sieve Approach - Generate an array containing prime numbers void prime_sieve(int p){ // First mark all the odd numbers as potential prime numbers for(int i=3;i<=1000;i=+2){ p[i]=1; // Initialize all values as 1 } // Sieve Code for(int i=3;i<=1000;i+=2){ // If the current number is not marked (It is a prime number) if(p[i]==1){ // mark all the multiples of i as not prime for(int j=ii;j<=1000;j+=i){ p[j]=0; // Mark the values as 0 that are not prime } } } // Some Special Cases p[2]=1; p[1]=p[0]=0; } int main(){ int p[1005]={0}; prime_sieve§; int csum[1000]={0}; // lets print all prime numbers upto range n for(int i=0;i<=1000;i++){ if(p[i]==1){ cout<<i<<" "; } } /* // Precompute the primes upto index i for(int i=1;i<1000;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; }
hi @kartikgoyal794_20c73381f539afcf, please save it here ide.codingblocks.com and send the link here your code is not readable see this
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.