Skip to content

Instantly share code, notes, and snippets.

@rinx
Created November 18, 2015 03:21
Show Gist options
  • Save rinx/f60d247d6e5fd82e52e3 to your computer and use it in GitHub Desktop.
Save rinx/f60d247d6e5fd82e52e3 to your computer and use it in GitHub Desktop.
An example of recursive function on fortran.
program main
print *, fib(30)
contains
recursive function fib(n) result(res)
integer :: n
integer :: res
if (n <= 2) then
res = 1
else
res = fib(n-1) + fib(n-2)
endif
end function fib
end program main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment