aboutsummaryrefslogtreecommitdiff
path: root/tests/sysy_lvX/056_factorial.sy
diff options
context:
space:
mode:
Diffstat (limited to 'tests/sysy_lvX/056_factorial.sy')
-rw-r--r--tests/sysy_lvX/056_factorial.sy12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/sysy_lvX/056_factorial.sy b/tests/sysy_lvX/056_factorial.sy
new file mode 100644
index 0000000..9969409
--- /dev/null
+++ b/tests/sysy_lvX/056_factorial.sy
@@ -0,0 +1,12 @@
+//get 1*2*3*4*5
+int factorial(int n)
+{
+ if(n <= 1)
+ return 1;
+ else
+ return n * factorial(n-1);
+}
+
+int main(){
+ return factorial(5);
+} \ No newline at end of file