Skip to content

Instantly share code, notes, and snippets.

@nazgob
Created March 18, 2010 21:38
Show Gist options
  • Save nazgob/336927 to your computer and use it in GitHub Desktop.
Save nazgob/336927 to your computer and use it in GitHub Desktop.
Stirling number of the second kind
#include <iostream>
size_t S(size_t n, size_t k)
{
if(k > n)
{
return 0;
}
else if(k == 1)
{
return 1;
}
else
{
return S(n-1, k-1) + k * S(n-1, k);
}
}
int main()
{
std::cout << S(6,4) << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment