ok, So I've been project eulering for a while now, and I've got a great sieve of Eratosthenes to find primes for me, and I see no reason why I'm not able to sum them, but for whatever reason, the value I receive for the sum, is the value of the prime at that number (when I choose the 148933th prime 1999993, the last prime below 2 million) i only receive 1999993 as the x variable, which I naturally set as xl = xl +currprime. It works for the 4th case (all primes below 10), but isn't working for the 148933th case. Does anyone know how I effed up?
thanks a bunch
int n = 44748364; //barely pullin through
boolean[] prime_array = new boolean[n+1];
int z = 0;
for (int i = 2; i<=n; i++) ///everything begins true
{
prime_array[i] = true;
}
for(int p_i = 2; p_i*p_i < n ; p_i++)
{
if(prime_array[p_i])
{
for(int p = p_i; p_i*p <=n; p++)
{
prime_array[p_i*p] = false;
}
}
}
float x = 0;
for(int p_i = 2; p_i < n ; p_i++)
{
if(prime_array[p_i]==true)
{
z = z + 1;
int xt = p_i;
x = x + xt;
}