Advertisement
Oppaceted

Untitled

Mar 3rd, 2023
996
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. program Fibon
  3.     implicit none
  4.     integer :: n, fibonacci
  5.     write (*,'(a$)') 'Enter n:'
  6.     read (*,*) n
  7.     write (*,'(i10)') fibonacci(n)
  8. end program Fibon
  9.  
  10. recursive function fibonacci(m) result(fibo)
  11.     integer :: m, fibo
  12.     if ( (m == 1) .or. (m == 2) ) then
  13.         fibo = 1
  14.     else
  15.         fibo = fibonacci(m-1) + fibonacci(m-2)
  16.     end if
  17. end function
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement