এটি একটি C++ প্রোগ্রাম যা রিকারেন্স রিলেশন ব্যবহার করে nCr কম্বিনেশন ক্যালকুলেট করে।
অ্যালগরিদম
শুরু
ফাংশন CalCombination():
আর্গুমেন্ট: n, r।
ফাংশনের বডি:
ফর্মুলা ব্যবহার করে কম্বিনেশন ক্যালকুলেট করুন:
n! / (r! * (n-r)!)
শেষ
উদাহরণ
#include <iostream>
using namespace std;
float CalCombination(float n, float r) {
int i;
if (r > 0)
return (n/r) * CalCombination(n-1, r-1);
else
return 1;
}
int main() {
float n, r;
int res;
cout << "Enter the value of n: ";
cin >> n;
cout << "Enter the value of r: ";
cin >> r;
res = CalCombination(n, r);
cout << "\nThe number of possible combinations are: nCr = " << res;
}
আউটপুট
Enter the value of n: 7 Enter the value of r: 6 The number of possible combinations are: nCr = 2