9 lines
153 B
C
9 lines
153 B
C
|
|
int factorialSafe(int n) {
|
||
|
|
int result = 1;
|
||
|
|
if(n<0)
|
||
|
|
return -1;
|
||
|
|
for (int i = 1; i <= n; ++i)
|
||
|
|
result *= i;
|
||
|
|
return result;
|
||
|
|
}
|