Program main
  Integer :: i
  Integer :: fact, fib
  do
    write (*,*) 'Which number you want factorial/fib of?-> '
    read (*,*) i
    if (i == 0) exit
    write (*,*) i, '!  is: ', fact(i)
    write (*,*) 'fib(',i,') = ',fib(i)
 end do
end Program main

Integer Recursive Function fact(n) result (ans)
  Integer, Intent(IN) :: n
  Integer :: ans
  if (n == 1) then
     ans = 1
  else
     ans = n * fact(n-1)
  end if
end Function fact

Integer Recursive Function fib(n) result (ans)
  Integer, Intent(IN) :: n
  Integer :: ans
  if (n == 1) then
     ans = 1
  else if (n == 2) then
     ans = 1
  else
     ans = fib(n-1) + fib(n-2)
  end if
end Function fib

