RosettaCodeData/Task/Factorial/Apex/factorial-2.apex
2016-12-05 23:44:36 +01: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);
}