Created
March 6, 2024 10:06
-
-
Save MitchiLaser/1420e173ec4827145f2dab04bab9006f to your computer and use it in GitHub Desktop.
Recursive lambda calculating Fibonacci number 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 <cstdlib> | |
int main( int argc, char* argv[]) { | |
typedef unsigned long long int num_type; | |
std::cout << [](auto lambda, num_type number) -> num_type { return lambda(lambda, number); } ([](auto lambda, num_type number) -> num_type { return number <= 2 ? num_type(1) : lambda(lambda, number-1) + lambda(lambda, number-2); }, std::atoi(argv[1])) << std::endl; | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment