Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/geometry/triangulation/functions.cc
4056 views
1
#include "functions.h"
2
3
// ------- auxiliary functions ----------------------------
4
int factorial(int n)
5
{
6
int result=1;
7
for (int i=1; i<=n; i++)
8
result*=i;
9
return(result);
10
}
11
12
13
// binomial works only well for "normal" values
14
int binomial(int n, int D)
15
{
16
int d=D;
17
if (d>n/2) d=n-d;
18
int result=1;
19
for (int i=0; i<d; i++)
20
result*=n-i;
21
for (int i=1; i<=d; i++)
22
result/=i;
23
return(result);
24
}
25
26