title: Find next prime number algorithm
body: <p>I am looking forward to improve my algorithm to find the next primenumber to the right to a given number.
  What I have so far is this:</p>
  
  <pre><code>int NextPrime(int a)
  {
      int i, j, count, num;
      for (i = a + 1; 1; i++)
      {
          for (j = 2, count = 0; j &lt;= i; j++)
          {
              if (i%j == 0)
              {
                  count++;
              }
          }
          if (count == 1)
          {
              return i;
              break;
          }
      }
  }
  </code></pre>
  
  <p>Tho this algorithm is not that efficent when running often.
  Can someone give advices on how the algorithm could be speed up or improved.</p>