title: Finding total of prime numbers between two x1,x2, cant find mistake?
body: <p>I need to find the sum of prime numbers between two numbers, say x1 and x2 inclusively, however i cant detect whats wrong?
  for example if i entered 3 and 9 i would get 15 but i am getting 133!</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int prime(int n1, int n2)
  {
      int  count =0;
      bool prime = true;
  
      for (n1; n1 &lt; n2; n1++)
      {
          for (int i = 2; i &lt; n1; i++)
          {
              if (n1 % i == 0) {
                  prime = false;
                  continue;
              }
              else
                  count++;
          }
      }
      return count;
  
  }
  int main()
  {
      int n1, n2;
      cout &lt;&lt; " Enter values for n1 and n2 (n1 must be smaller than n2):   ";
      cin &gt;&gt; n1&gt;&gt;n2;
  
  
      cout &lt;&lt; " Sum of prime numbers from " &lt;&lt; n1 &lt;&lt; " and till " &lt;&lt; n2 &lt;&lt; " inclusively : " &lt;&lt; prime(n1, n2) &lt;&lt; endl;
      system("pause");
      return 0;
  }
  </code></pre>