Recursive GCD using a lambda This works just fine, however, the assignment was to write a recursive "function".  I'm curious to see if this should count. 

Any comments / suggestions/ stuff I should watch out for are appreciated. 

#include &lt;iostream&gt;
#include &lt;functional&gt;
#include &lt;cctype&gt;
#include &lt;cstdlib&gt;

int main() {

    char go_again = 'Y';

    do {

        int lhs, rhs;
        std::cout &lt;&lt; "Enter 2 integer values: ";
        std::cin &gt;&gt; lhs &gt;&gt; rhs;

        if (lhs &lt; 0 || rhs &lt; 0)
            std::cout &lt;&lt; "Implicit converstion to positive integers.\n";

        std::function&lt;int(int, int)&gt; 
            gcd = [&amp;](int lhs, int rhs) -&gt; int { 
                return rhs == 0 ? std::abs(lhs) : gcd(rhs, lhs % rhs); 
        };

        std::cout &lt;&lt; "gcd == " &lt;&lt; gcd(lhs, rhs) &lt;&lt; '\n';
        std::cout &lt;&lt; "Go again? &lt;Y/N&gt; ";
        std::cin &gt;&gt; go_again;

    } while (std::toupper(go_again) == 'Y');

}
Not that familiar with C++, but that certainly looks like recursion to me...

The variable gcd contains a function, which then calls itself.  The very definition of recursion.

But I would ask what you gain by not making it a regular function?