Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
18
Task/Anonymous-recursion/Fortran/anonymous-recursion.f
Normal file
18
Task/Anonymous-recursion/Fortran/anonymous-recursion.f
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
integer function fib(n)
|
||||
integer, intent(in) :: n
|
||||
if (n < 0 ) then
|
||||
write (*,*) 'Bad argument: fib(',n,')'
|
||||
stop
|
||||
else
|
||||
fib = purefib(n)
|
||||
end if
|
||||
contains
|
||||
recursive pure integer function purefib(n) result(f)
|
||||
integer, intent(in) :: n
|
||||
if (n < 2 ) then
|
||||
f = n
|
||||
else
|
||||
f = purefib(n-1) + purefib(n-2)
|
||||
end if
|
||||
end function purefib
|
||||
end function fib
|
||||
Loading…
Add table
Add a link
Reference in a new issue