title: Efficient way to determine if a pixel is in safe bounds
body: <p>I have the following code: <br></p>
  <pre><code>int isSafe(int pixelNumber, int safeStart, int safeWidth, int height, int width)
  {
      for (int i = 0; i &lt; height; i++)
      {
          if (safeStart + width * i &lt;= pixelNumber &amp;&amp; pixelNumber &lt; safeStart + width * i + safeWidth)
              return 1;
      }
      return 0;
  }
  </code></pre>
  <p>This tells if a pixel is safe or not. So I will be calling this function several times <br>
  for several pixel values from 0 to some number. Is there some way to code it more efficiently<br> so as to avoid running the forloop every time</p>