Created
October 18, 2017 11:18
-
-
Save esmitt/9f9eb159bc1c6f26e98f4aeda4723936 to your computer and use it in GitHub Desktop.
Fibonacci in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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