summaryrefslogtreecommitdiffstats
path: root/src/examples/recursive.ft
diff options
context:
space:
mode:
authorAidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com>2021-12-08 04:37:18 +0000
committerAidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com>2021-12-08 04:37:18 +0000
commit0d32b01fde73224469b8bb5971ebdaacd9bfa32c (patch)
treea6ff8bd4dbbf144cb112d24785b525ce2b59fb8a /src/examples/recursive.ft
parent5c4d41c63af3ef064090336a14efe91931051e7e (diff)
downloadesotericFORTRAN-0d32b01fde73224469b8bb5971ebdaacd9bfa32c.tar.gz
esotericFORTRAN-0d32b01fde73224469b8bb5971ebdaacd9bfa32c.zip
Fixed bug with function return and added recursive example
Diffstat (limited to 'src/examples/recursive.ft')
-rw-r--r--src/examples/recursive.ft14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/examples/recursive.ft b/src/examples/recursive.ft
new file mode 100644
index 0000000..d6f7a69
--- /dev/null
+++ b/src/examples/recursive.ft
@@ -0,0 +1,14 @@
+program recursive
+int::value
+int::final
+value=5
+final=factorial(value)
+print*,"The factorial of ",value," is ",final
+end program recursive
+
+function int factorial(int x)
+if x==1 then
+return 1
+end if
+return x*factorial(x-1)
+end \ No newline at end of file