After lots of trial and error, i found out that this NZEC error is not caused by the userinput part...
but it is caused when i call a method from my main method.
Any idea? or can someone give me elaboration on what exactly NZEC means so i can possibly find solution?
calcPrimes(cases);
private static int[] calcPrimes(int upperBound)
{
int bound = upperBound;
primes = new int[bound];
for(int i=0;i<bound;++i)
{
primes[i]=i+1;
}
{
int j=2;
//eratheosthese?? sieve
while(j<=Math.sqrt(bound))
{
for(int i=j+1;i<bound;++i) //j+1 because of the array starting at 0
{
if(primes[i]%j==0)
{
primes[i]=0;
}
}
++j;
}
int[] temp = new int[bound-countNonzero(primes)];
j=0;
for(int i=0;i<bound;++i)
{
if(primes[i] != 0)
{
temp[j] = primes[i];
++j;
}
}
primes = temp;
}
return primes;
}