Question: hi have a template with a form and many inputs that pass some data trough a POST request to a view, that process them and send the result to another template. in the final template, if i use the browser back button to jump to the first view, i can see again old data. i refresh the page and i insert new data, i submit again but some old data remain when i see the final view. the problem remain even if i restart the debug server. how can i prevent it? it seems that there's some data-caching that i can solve only flushing browser cache. this is the view code: <http://dpaste.com/640956/> and the first template code: <http://dpaste.com/640960/>

any idea?

tnx - luke

Answer: 
Here is my implementation.

```
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int* sieve(int n) {
  int* A = calloc(n, sizeof(int));
  for(int i = 2; i < (int) sqrt(n); i++) {
    if (!A[i]) {
      for (int j = i*i; j < n; j+=i) {
        A[j] = 1;
      }
    }
  }
  return A;
}

```

I benchmarked it for the first 1,000,000,000 numbers on an i5 Kaby Lake.

```
 time ./sieve 1000000000
./sieve 1000000000  16.21s user 1.05s system 99% cpu 17.434 total

```

I simply translated [this](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#Algorithm_and_variants) pseudocode from Wikipedia.
**Simple implementation of Sieve of Eratosthenes**

**Approach:**
I have created a boolean vector of size n+1(say n=9 then 0 to 9)that holds true at all places. Now, *for i=2* mark all the places that are *multiple of 2 as **false***(like 4,6 and 8 when n=9). For *i=3*, mark all the places that are *multiple of 3 as **false***(like 6 and 9 when n=9). Now, for i=4 condition **i\*i<=n** is ***false*** because 4\*4 =16 > 9. So, now print all the places that hold true value.

```
void sieve(int n)
{
vector<bool> isPrime(n+1,true);
for(int i=2;i*i<=n;i++){
    if(isPrime[i])
    {
       for(int j=2*i;j<=n;j=j+i)
           isPrime[j]=false;
     }
  }
 for(int i=2;i<=n;i++){
    if(isPrime[i])
        cout<<i<<" ";
  }
}

```