From 4f3113e678ca61c8b7abf5bc760a02245609124d Mon Sep 17 00:00:00 2001 From: andre Date: Mon, 24 Jun 2024 01:50:37 +0200 Subject: [PATCH] =?UTF-8?q?fakult=C3=A4t-Methode=20einfacher=20gestaltet,?= =?UTF-8?q?=20wegen=20Diagramm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PR1_Pflichtuebung6/src/ueb6/Rechner.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PR1_Pflichtuebung6/src/ueb6/Rechner.java b/PR1_Pflichtuebung6/src/ueb6/Rechner.java index 7143428..b8928ee 100644 --- a/PR1_Pflichtuebung6/src/ueb6/Rechner.java +++ b/PR1_Pflichtuebung6/src/ueb6/Rechner.java @@ -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); + } + } } \ No newline at end of file