Add all the A tasks
This commit is contained in:
parent
2dd7375f96
commit
051504d65b
1608 changed files with 18584 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