fork(2) download
  1. #include <iostream>
  2. #include <functional>
  3. using namespace std;
  4.  
  5. std::function<int(int)> f;
  6.  
  7. int main() {
  8. // your code goes here
  9.  
  10. f = [](int a) { if (a==0) return 1; else return a*f(a-1); };
  11.  
  12. int a = f(3);
  13.  
  14. std::cout << "a: " << a << std::endl;
  15. return 0;
  16. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
a: 6