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 was my implementation (Java)
much simpler in that you really only need one array, just start for loops at 2. 

edit: @cheesehead 's solution was probably better, i just read the description of the sieve and thought it would be a good thought exercise.

```
      // set max;
      int max = 100000000;

      // logic
      boolean[] marked = new boolean[max]; // all start as false
      for (int k = 2; k < max;) {
         for (int g = k * 2; g < max; g += k) {
            marked[g] = true;
         }
         k++;
         while (k < max && marked[k]) {
            k++;
         }
      }

      //print
      for (int k = 2; k < max; k++) {
         if (!marked[k]) {
            System.out.println(k);
         }
      }

```
**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<<" ";
  }
}

```