fakultät-Methode einfacher gestaltet, wegen Diagramm

master
andre 2024-06-24 01:50:37 +02:00
parent 1aa15e069c
commit 4f3113e678
1 changed files with 4 additions and 4 deletions

View File

@ -230,11 +230,11 @@ public class Rechner {
if (n < 0) {
throw new IllegalArgumentException("Zahl darf nicht negativ sein.");
} else if (n == 0)
return 0;
else if (n == 1 || n == 2)
return n;
return 1;
else {
return fakultaet(n-1) * n;
return n * fakultaet(n-1);
}
}
}