CodePudding user response:
Feel this formula cannot be directly calculated by program, at least n! Is a large number, 100! Can't say computer int, need to be simplified formula?CodePudding user response:
Direct arrangement number P (n, r) calculation is not ok?P (n, r)=n (n - 1) (n - 2)... (n - r + 1)
You this is p (n, 5)=n (n - 1) (n - 2)... 5 + (n - 1)
Int n;
Cin> n;
Int ret=1;
For (int r=1; i<=5; I++)
{
Ret *=n - (I) + 1;
}//ret result is
CodePudding user response:
But n is too large, ret will overflow, but as a homework, your teacher will not consider these,