un-inception/test/fib.f90
Russell Ballestrini 2b35819393 Initial commit: 42 UN CLI implementations
Unsandbox CLI implementations in 42 programming languages for the
permacomputer project. Public domain software for code execution
across all ecosystems.

Languages: Python, JavaScript, Ruby, Go, Rust, C, C++, Java, Kotlin,
C#, F#, Haskell, OCaml, Clojure, Scheme, Common Lisp, Erlang, Elixir,
D, Nim, Zig, V, Dart, Groovy, Scala, Julia, R, Crystal, Fortran,
COBOL, Prolog, Forth, Tcl, Raku, Lua, PHP, Perl, Bash, TypeScript,
Objective-C, PowerShell, AWK

Includes test suites and service lifecycle tests.
2025-12-23 09:57:08 -05:00

20 lines
352 B
Fortran

program fibonacci
implicit none
integer :: i
do i = 0, 10
print '(A,I0,A,I0)', 'fib(', i, ') = ', fib(i)
end do
contains
recursive function fib(n) result(res)
integer, intent(in) :: n
integer :: res
if (n <= 1) then
res = n
else
res = fib(n-1) + fib(n-2)
end if
end function fib
end program fibonacci