static int[] a = new int[100];
static int index = 3;
static
{
a[0]=2;
a[1]=3;
a[2]=5;
a[3]=7;
}
public int nextPrime(int n)
{
//creat an arry.
//divide the number with all the prime numbers you have so far.
//if none of them results in a reminder of zero,
//then the number must be prime.
//you add this new prime number to the collection of primes you have so far.
//then return the prime number
while(true)
{
for(int i=0; i<a.length ; i++)
{
if(n%a[i]!=0)
a[index+1]=n;
else
n=n+1;
}
return index;
}
}