/**
* This class is used to compute prime numbers.
* @author christian
*
*/
public class Prime {
/**
* Counts prime numbers up to a specified bound.
* @param bound Count up to this number.
* @return Number of primes.
*/
public int countPrimesUpTo(int bound){
int count = 0;
for(int i = 2; i <= bound; i++){
}
return count;
}
/**
* Checks whether an integer is a prime number or not.
* @param number Number to be checked.
* @return true if number is prime, false otherwise.
*/
if(number == 1){
return false;
}else if(number == 2){
return true;
return false;
}else{
if (number % i == 0) return false;
}
}
return true;
}
/**
* Returns a formatted string of the first prime numbers up to bound. (e.g. '[2, 3, 5, 7]')
* @param bound Highest number that should be tested.
* @return String containing prime numbers up to bound.
*/
boolean format = false;
for(int i = 2; i <= bound; i++){
if (this.isPrime(i)){
string += i;
format = true;
}
}
return string += "]";
}
}