Find the value of f ( n ) / f ( r ) * f ( n | CPP to find the value of f ( n ) / f ( r ) * f ( n - r ) ; Function to find value of given F ( n ) ; iterate over n ; calculate result ; return the result ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int calcFunction ( int n , int r ) { int finalDenominator = 1 ; int mx = max ( r , n - r ) ; for ( int i = mx + 1 ; i <= n ; i ++ ) { int denominator = ( int ) pow ( i , i ) ; int numerator = ( int ) pow ( i - mx , i - mx ) ; finalDenominator = ( finalDenominator * denominator ) / numerator ; } return finalDenominator ; } int main ( ) { int n = 6 , r = 2 ; cout << "1 / " << calcFunction ( n , r ) << endl ; return 0 ; }