Solución
solution.tsTypeScript
public class Solution {
public int factorial(int value) {
/* improve
if (value < 0) {
throw new IllegalArgumentException(
"Factorial is not defined for negative integers"
);
}
*/
if (value == 0 || value == 1) return 1;
int result = 1;
for (int i = 2; i <= value; i++) {
result *= i;
}
return result;
}
}0respuestas