Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Fibon
- implicit none
- integer :: n, fibonacci
- write (*,'(a$)') 'Enter n:'
- read (*,*) n
- write (*,'(i10)') fibonacci(n)
- end program Fibon
- recursive function fibonacci(m) result(fibo)
- integer :: m, fibo
- if ( (m == 1) .or. (m == 2) ) then
- fibo = 1
- else
- fibo = fibonacci(m-1) + fibonacci(m-2)
- end if
- end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement