the-honk/languages/c/calculators/helpers/factorial.c

9 lines
101 B
C

int factorial(int n) {
int ans = 1;
for (int i = 2; i <= n; i++) {
ans *= i;
}
return ans;
}