Skip to content

Instantly share code, notes, and snippets.

@satojkovic
Created May 29, 2013 13:27
Show Gist options
  • Save satojkovic/5670242 to your computer and use it in GitHub Desktop.
Save satojkovic/5670242 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int fact(int k)
{
if( k == 0 ) return 1;
return k * fact(k-1);
}
int permutations(int n, int r)
{
return (fact(n) / fact(n-r));
}
int main()
{
int n = 4;
int r = 3;
int p = permutations(n, r);
cout << "permutations(" << n << "," << r << ") = " << p << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment