Monday, November 29, 2010

GET NEXT 10 PRIME NUMBER FROM ENTERED VALUE

// find and print the next prime
import java.math.BigInteger;
public class Next_10_Primes
{
public static void main(String[] args)
  {
  int i;
  BigInteger x = new BigInteger(args[0]);    // constructor
  BigInteger y = new BigInteger("0");        // constructor

  System.out.println("The next 10 primes after\n" + x.toString(10) + "\nare\n");
  for ( i = 0 ; i < 10 ; i ++ )
    {
    y = FindNextPrime.nextprime(x);
    System.out.println(" " + y.toString(10));
    x = y;
    }
  }
}

No comments:

Post a Comment