RosettaCodeData/Task/Factorial/Apex/factorial-2.apex
2023-07-01 13:44:08 -04:00

7 lines
175 B
Text

public static long factRec(final Integer n) {
if (n < 0){
System.debug('No negative numbers');
return 0;
}
return (n < 2) ? 1 : n * fact(n - 1);
}