Created
May 29, 2013 13:27
-
-
Save satojkovic/5670242 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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