Skip to content

Instantly share code, notes, and snippets.

@phabee
Created October 4, 2020 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phabee/2f7deb04390dd9e45267e04918600831 to your computer and use it in GitHub Desktop.
Save phabee/2f7deb04390dd9e45267e04918600831 to your computer and use it in GitHub Desktop.
tic
fibonacci(30)
toc
function [n] = fibonacci(x)
if (x == 1 || x==0)
n = x;
else
n = fibonacci(x-1) + fibonacci(x-2);
end
return;
end
@phabee
Copy link
Author

phabee commented Oct 4, 2020

Simple matlab script to calculate n-th fibonacci number using recursion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment