Skip to content

Instantly share code, notes, and snippets.

@kaneshin
Created October 1, 2011 17:23
Show Gist options
  • Save kaneshin/1256358 to your computer and use it in GitHub Desktop.
Save kaneshin/1256358 to your computer and use it in GitHub Desktop.
" Fibonacci number - vim
command! -nargs=1 Fibonacci :echo s:fibonacci(<f-args>)
function! s:fibonacci(n)
if a:n < 1
return 1 " F_0
elseif a:n == 1
return 1 " F_1
endif
return s:fibonacci(a:n - 1) + s:fibonacci(a:n - 2)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment