aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Chan2022-10-24 03:07:43 +0000
committerJonathan Chan2022-10-24 03:09:47 +0000
commit4c717196fd630c5c207e114ffa9ca9c301eb1198 (patch)
tree0c661bc22bd5856c4d74588d65c92db280bc7799
parentd0208871d8c9cf86541b56afe6b830c5a20eb2c2 (diff)
Fortran :) (also moved my Agda file up a dir)
-rw-r--r--README.md3
-rw-r--r--entries/ionathanch/Fib.agda (renamed from entries/ionathanch/agda/Fib.agda)0
-rw-r--r--entries/ionathanch/fib.f9021
3 files changed, 23 insertions, 1 deletions
diff --git a/README.md b/README.md
index 51ade8f..0fcbc53 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,8 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
<!-- - `imperitive-church` imperitive implementation in the lambda calculus -->
### [`ionathanch`](https://github.com/ionathanch)
-- [`agda`](./entries/ionathanch/agda/Fib.agda)
+- [`agda`](./entries/ionathanch/Fib.agda)
+- [`fortran`](./entries/ionathanch/fib.f90)
### [`funemy`](https://github.com/funemy)
- [`agda`](./entries/funemy/agda/fib1.agda)
diff --git a/entries/ionathanch/agda/Fib.agda b/entries/ionathanch/Fib.agda
index a12b0a5..a12b0a5 100644
--- a/entries/ionathanch/agda/Fib.agda
+++ b/entries/ionathanch/Fib.agda
diff --git a/entries/ionathanch/fib.f90 b/entries/ionathanch/fib.f90
new file mode 100644
index 0000000..3cf1850
--- /dev/null
+++ b/entries/ionathanch/fib.f90
@@ -0,0 +1,21 @@
+PROGRAM main
+ ! The 93rd Fibonacci number is the largest that fits in 64 bits anyway
+ CHARACTER(3) :: kth
+ INTEGER :: k
+ CALL get_command_argument(1, kth)
+ READ(kth, *) k
+ WRITE(*, *) fib(k)
+CONTAINS
+
+PURE RECURSIVE INTEGER*8 FUNCTION fib(k) RESULT(n)
+ INTEGER, INTENT (IN) :: k
+ IF (k == 0) THEN
+ n = 0
+ ELSE IF (k == 1) THEN
+ n = 1
+ ELSE
+ n = fib(k - 1) + fib(k - 2)
+ END IF
+END FUNCTION fib
+
+END PROGRAM