From 4c717196fd630c5c207e114ffa9ca9c301eb1198 Mon Sep 17 00:00:00 2001 From: Jonathan Chan Date: Sun, 23 Oct 2022 23:07:43 -0400 Subject: Fortran :) (also moved my Agda file up a dir) --- entries/ionathanch/fib.f90 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 entries/ionathanch/fib.f90 (limited to 'entries/ionathanch/fib.f90') 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 -- cgit v1.2.3-70-g09d2