You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
345 B
23 lines
345 B
|
|
|
|
#include "calculateFactorial.h"
|
|
|
|
// Function for Factorial with integer
|
|
int calculateFactorial_integer(int n) {
|
|
if (n < 0) {
|
|
|
|
} else if (n == 0 || n == 1) {
|
|
|
|
return 1;
|
|
} else {
|
|
|
|
int result = 1;
|
|
for (int i = 2; i <= n; ++i) {
|
|
result *= i;
|
|
}
|
|
return result;
|
|
}
|
|
return 0;
|
|
|
|
}
|
|
|