From e9c1160993db9e3270d91bcc9055b283f7fb4dd2 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 25 Jun 2025 10:53:27 +0800 Subject: [PATCH] =?UTF-8?q?test=EF=BC=9A=E5=A2=9E=E5=8A=A0=20Demo9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playground/Demo9/Main.snow | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 playground/Demo9/Main.snow diff --git a/playground/Demo9/Main.snow b/playground/Demo9/Main.snow new file mode 100644 index 0000000..46749dd --- /dev/null +++ b/playground/Demo9/Main.snow @@ -0,0 +1,31 @@ +module: Math + function: main + parameter: + return_type: int + body: + Math.factorial(6) + return 0 + end body + end function + + function: factorial + parameter: + declare n:int + return_type: int + body: + declare num1:int = 1 + loop: + initializer: + declare counter:int = 1 + condition: + counter <= n + update: + counter = counter + 1 + body: + num1 = num1 * counter + end body + end loop + return num1 + end body + end function +end module