Skip to content

Commit

Permalink
Update fib.f03
Browse files Browse the repository at this point in the history
Code optimizaton
  • Loading branch information
shrx authored Sep 28, 2018
1 parent eb8e9c0 commit 5cdd5ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fib.f03
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
program fibonacci
implicit none

write(*,*) fib_rec(47)
write(*,*) fib_rec(46)

contains
recursive function fib_rec(n) result(fib)
integer, intent(in), value :: n
integer*8 :: fib

if (n <= 1) then
fib = n
fib = 1
else
fib = fib_rec(n - 1) + fib_rec(n - 2)
end if
Expand Down

0 comments on commit 5cdd5ca

Please sign in to comment.