Adding primes in a sequence in C++
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8875105/adding-primes-in-a-sequence-in-c">Adding primes in a sequence in C++</a>  </p>
</blockquote>



<p>Consider <em>n</em> a sequence of positive integers <em>n</em>, calculate the <strong>sum</strong> of the numbers of sequences that are cousins.</p>

<p>How do I do that? I tried the following code but failed:</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;
int main()
{
    int n, i, j, numero = 0, primo = 0, soma = 0;
    cout &lt;&lt; "Digite um numero: ";
    cin &gt;&gt; n;
    for (i = 0; i &lt; n; i++)
    {
        cin &gt;&gt; numero;
        for (j = 1; j &lt; n; j++)
        cout &lt;&lt; " numero " &lt;&lt; numero &lt;&lt; endl;
        {
            if (numero %j == 0)
                primo ++;
                cout &lt;&lt; "primo" &lt;&lt; primo &lt;&lt; endl;
        }
        if (primo == 2)
        {
            soma = soma + numero;
            cout &lt;&lt; " numero " &lt;&lt; numero &lt;&lt; endl;
            cout &lt;&lt; "soma" &lt;&lt; soma &lt;&lt; endl;
        }
    }
    cout &lt;&lt; soma &lt;&lt; endl;
    return 0;
}
</code></pre>
