#include <iostream>
#include <functional>
int main()
{
std::function<long(int)> lambda = [&](int x) -> long {
if (x != 0)
return x+lambda(x-1);
else
return 0;
};
std::cout << lambda(20) << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KCmludCBtYWluKCkKewogICAgc3RkOjpmdW5jdGlvbjxsb25nKGludCk+IGxhbWJkYSA9IFsmXShpbnQgeCkgLT4gbG9uZyB7CiAgICAgICAgaWYgKHggIT0gMCkKICAgICAgICAgICAgcmV0dXJuIHgrbGFtYmRhKHgtMSk7CiAgICAgICAgZWxzZQogICAgICAgICAgICByZXR1cm4gMDsKICAgIH07CiAgICBzdGQ6OmNvdXQgPDwgbGFtYmRhKDIwKSA8PCBzdGQ6OmVuZGw7CiAgICByZXR1cm4gMDsKfQ==