Run error coming
hi @G_rahil
The 5,000,000th prime is 86,028,121.
so atleast this much space you require
as size of array is very large and you need to save only 1 or 0
so rather than integer array
use bool arr[100000002]={};
do some more optimzations like
rather than marking all odd as 1 assuming 0 represent prime no
you can take help from this
// PrimeSeive.cpp
#include<iostream>
#include<vector>
using namespace std;
#define ll long long int
bool prime [100000005]={};
vector<int> Prime;
int main(){
prime[0]=prime[1]=true;
Prime.push_back(2);
for(ll i=3;i<100000001;i+=2){
if(!prime[i]){
Prime.push_back(i);
for(ll j=i*i;j<100000001;j+=i){prime[j]=true;}
}
}
int n;cin>>n;
cout<<Prime[n-1]<<endl;
return 0;
}
if you have doubts in this code or in your code
feel free to ask