|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void checkNumbers(int grenze) {
|
|
|
public void checkNumbers(int grenze) {
|
|
|
for (int i = 1; i <= grenze; i++) {
|
|
|
for (int i = 1; i <= grenze; i++) {
|
|
|
checkDevideByFive(i);
|
|
|
|
|
|
checkEndsWithNine(i);
|
|
|
|
|
|
checkSumWithPrev(i);
|
|
|
|
|
|
|
|
|
if (filter(i)){
|
|
|
|
|
|
System.out.println(i);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public boolean filter(int i){
|
|
|
|
|
|
return !(checkDivideByFive(i) || checkEndsWithNine(i) || checkSumWithPrev(i)) ;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private void checkDevideByFive(int zahl) {
|
|
|
|
|
|
if (zahl % 5 == 0) {
|
|
|
|
|
|
System.out.println(zahl + " ist durch 5 teilbar!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private Boolean checkDivideByFive(int i) {
|
|
|
|
|
|
return i % 5 == 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkEndsWithNine(int zahl) {
|
|
|
|
|
|
if (zahl % 10 == 9) {
|
|
|
|
|
|
System.out.println(zahl + " endet auf 9!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private Boolean checkEndsWithNine(int i) {
|
|
|
|
|
|
return i % 10 == 9;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkSumWithPrev(int zahl) {
|
|
|
|
|
|
if (zahl > 1) {
|
|
|
|
|
|
int vorgaenger = zahl - 1;
|
|
|
|
|
|
int summe = zahl + vorgaenger;
|
|
|
|
|
|
if (summe % 3 == 0) {
|
|
|
|
|
|
System.out.println(zahl + " und " + vorgaenger + " addiert ergeben " + summe + " und " + summe + " ist durch 3 teilbar.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
private Boolean checkSumWithPrev(int i) {
|
|
|
|
|
|
if (i > 1) {
|
|
|
|
|
|
int vorgaenger = i - 1;
|
|
|
|
|
|
int summe = i + vorgaenger;
|
|
|
|
|
|
return summe % 3 == 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|