From 48983c14a2c58b9e129803e9b4cd1eda0b85b966 Mon Sep 17 00:00:00 2001
From: "Dr. Martin Goik" <goik@hdm-stuttgart.de>
Date: Wed, 14 Apr 2021 16:22:53 +0200
Subject: [PATCH] 0! == 1 corrected

---
 Doc/Sd1/statements.xml | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/Doc/Sd1/statements.xml b/Doc/Sd1/statements.xml
index 584613774..8a50c45e7 100644
--- a/Doc/Sd1/statements.xml
+++ b/Doc/Sd1/statements.xml
@@ -2280,6 +2280,25 @@ while (counter++ &lt; 10) {
                 </m:math>
               </informalequation>
 
+              <para>In addition the factorial of zero is being defined
+              as:</para>
+
+              <informalequation>
+                <m:math display="block">
+                  <m:mrow>
+                    <m:mrow>
+                      <m:mi>0</m:mi>
+
+                      <m:mo>!</m:mo>
+                    </m:mrow>
+
+                    <m:mo>=</m:mo>
+
+                    <m:mn>1</m:mn>
+                  </m:mrow>
+                </m:math>
+              </informalequation>
+
               <para>Write an application asking a user for an integer value
               and calculate the corresponding factorial e.g.:</para>
 
@@ -2294,11 +2313,11 @@ while (counter++ &lt; 10) {
     System.out.print("Enter an integer value: ");
     final int value = scan.nextInt();
 
-    long factorial = value;
-    int i = value;
+    long factorial = 1;
+    int i = 1;
 
-    while (1 &lt; --i) {
-      factorial *= i;
+    while (i++ &lt; value) {
+       factorial *= i;
     }
 
     System.out.println(value + "! == " + factorial);
-- 
GitLab