Skip to content

Instantly share code, notes, and snippets.

@esmitt
Created October 18, 2017 11:18
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 esmitt/9f9eb159bc1c6f26e98f4aeda4723936 to your computer and use it in GitHub Desktop.
Save esmitt/9f9eb159bc1c6f26e98f4aeda4723936 to your computer and use it in GitHub Desktop.
Fibonacci in C++
#include <iostream>
#include <functional>
int main()
{
std::function<int(int)> fib = [&fib](int n) {return n < 2 ? 1 : fib(n-1) + fib(n-2);};
std::cout << fib(9) << std::endl;
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment