Class PrimeNumbers

java.lang.Object
de.hdm_stuttgart.mi.sd1.main.PrimeNumbers

public class PrimeNumbers extends Object
Calculate prime numbers in a yet inefficient way
  • Constructor Details

  • Method Details

    • main

      public static void main(String[] args)
      Parameters:
      args - unused
    • findPrimeNumbers

      public static long findPrimeNumbers(long limit)
      Find all prime numbers up to a given limit.
      Parameters:
      limit - Test all integers from [2, limit] whether they are prime numbers or not.
      Returns:
      The number of primes found within [2, limit].
      Precondition:
      2 <= limit
    • isPrime

      public static boolean isPrime(long candidate)
      Test, whether a given number is prime.
      Parameters:
      candidate - The number to be assessed
      Returns:
      true if candidate is prime, false otherwise
      Precondition:
      2 <= candidate