Class Primes

java.lang.Object
com.softsynth.jmsl.util.Primes

public class Primes
extends java.lang.Object
use sieve of eratosthenes to find prime number nearest to requested value.
Author:
Nick Didkovsky
  • Constructor Summary

    Constructors
    Constructor Description
    Primes()  
  • Method Summary

    Modifier and Type Method Description
    static void main​(java.lang.String[] args)  
    static int nearest​(int value)
    Calculate prime number nearest to value.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Primes

      public Primes()
  • Method Details

    • nearest

      public static int nearest​(int value)
      Calculate prime number nearest to value. Will first recalculate entire sieve if value > sieve.length/2
      Returns:
      prime number nearest to value
    • main

      public static void main​(java.lang.String[] args)