Package de.hdm_stuttgart.mi.sd1.main
Class PrimeNumbers
java.lang.Object
de.hdm_stuttgart.mi.sd1.main.PrimeNumbers
Calculate prime numbers in a yet inefficient way
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
findPrimeNumbers
(long limit) Find all prime numbers up to a given limit.static boolean
isPrime
(long candidate) Test, whether a given number is prime.static void
-
Constructor Details
-
PrimeNumbers
public PrimeNumbers()
-
-
Method Details
-
main
- Parameters:
args
- unused
-
findPrimeNumbers
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
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
-