package task5;

public class PrimeNumberGenerator {
    private int maximum;

    public PrimeNumberGenerator(int maximum) {
        this.maximum = maximum;
    }
    public void printPrimeNumbers() {
        for (int i = 2; i <= maximum; i++) {
            if (isPrime(i)) {
                System.out.println(i);
            }
        }
    }
    private boolean isPrime(int number) {
        for (int i = 2; i < number; i++) {
            if (number % i == 0) {
                return false;
            }
        }
        return true;
    }
    public int countPrimeNumbers() {
        int count = 0;
        for (int i = 2; i <= maximum; i++) {
            if (isPrime(i)) {
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        int[] testValues = {100, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000};

        System.out.println("maximum,Anzahl Primzahlen (Algorithmus),maximum/ln(maximum) (Schätzung)");
        for (int max : testValues) {
            PrimeNumberGenerator generator = new PrimeNumberGenerator(max);
            int counted = generator.countPrimeNumbers();
            double estimated = max / Math.log(max);
            System.out.printf("%d,%d,%.1f%n", max, counted, estimated);
        }
    }
}
