I am trying to solve Prime Generator problem and using the sieve of erasthones Algorithm to finding the prime number between two number of large range (m and n (1 <= m <= n <= 1000000000, n-m<=100000) ) and getting RunTime Error related to memory i.e. due to large number the array index fails. Please anyone help me how to use sieve of erasthones Algorithm for this problem.

```
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
void printPrimeNumbers(unsigned long long int start,unsigned long long int end)
{
unsigned long long int i,j;
unsigned long long int *arr = (unsigned long long int *)malloc(sizeof(unsigned long long int)*(end+1));
for(i = 2;i < end;i++)
{
if(arr[i] == 0)
for(j = 2; i*j < end; j++)
arr[i*j] = -1;
}
for(i=start-1; i < end; i++)
if(arr[i] == 0)
printf("%llu\n",i);
}
int main()
{
int t;
scanf("%d",&t);
unsigned long long int a,b;
while(t--)
{
scanf("%llu%llu",&a,&b);
printPrimeNumbers(a,b);
}
return 0;
}
```

link of the solution.link text

Thanks in advance