Order the Book

coreservlets
Class Primes

java.lang.Object
  |
  +--coreservlets.Primes

public class Primes
extends Object

A few utilities to generate a large random BigInteger, and find the next prime number above a given BigInteger.

Taken from Core Servlets and JavaServer Pages from Prentice Hall and Sun Microsystems Press, http://www.coreservlets.com/. © 2000 Marty Hall; may be freely used or adapted.


Constructor Summary
Primes()
           
 
Method Summary
static void main(String[] args)
          Simple command-line program to test.
static BigInteger nextPrime(BigInteger start)
           
static BigInteger random(int numDigits)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Primes

public Primes()
Method Detail

nextPrime

public static BigInteger nextPrime(BigInteger start)

random

public static BigInteger random(int numDigits)

main

public static void main(String[] args)
Simple command-line program to test. Enter number of digits, and it picks a random number of that length and then prints the first 50 prime numbers above that.

Order the Book

Order
CSAJSP @ amazon.com

Return to Top-Level Source Code Archive