title: How to make this bash prime generator faster [SPOJ]
body: <p>I'm doing the SPOJ challenge named Prime Generator, however in BASH, the judge says  </p>
  
  <blockquote>
    <p>time limit
    exceeded</p>
  </blockquote>
  
  <p>The code gives requested results, and this algorythm was accepted in C++ and Java</p>
  
  <pre><code>#!/bin/bash
  
  read ITERATIONS
  
  for (( i=0; i&lt;$ITERATIONS; i++ ))
  do
          read START END
  
          for (( j=$START; j&lt;=$END; j++ ))
          do
                  isPrime=1
  
                  if [ $j -eq 1 ]
                  then
                          isPrime=0
                  fi
  
                  for (( k=2; k*k&lt;=$j; k++ ))
                  do
                          if (($j % $k == 0))
                          then
                                  isPrime=0
                                  break
                          fi
                  done
  
                  if [ $isPrime -eq 1 ]
                  then
                          echo "$j"
                  fi
          done
  done
  </code></pre>
  
  <p>My question is, how can I speed this code up? Did I do something silly that slows it down?</p>