recursive function f (n) result(res)
integer, value, intent(in) :: n
integer :: res
if (n == 0) then
res = 0
else if (n <= 2) then
res = 1
else
if (mod(n,2) == 1) then
res = f((n + 1)/2)**2 + f((n - 1)/2)**2
else
res = f(n/2) * (f(n/2-1) + f(n/2 + 1))
end if
end if
end function f
recursive function f (n) result(res)
integer, value, intent(in) :: n
integer :: res
if (n == 0) then
res = 0
else if (n <= 2) then
res = 1
else
if (mod(n,2) == 1) then
res = f((n + 1)/2)**2 + f((n - 1)/2)**2
else
res = f(n/2) * (f(n/2-1) + f(n/2 + 1))
end if
end if
end function f