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

  1. #include "calculateFactorial.h"
  2. // Function for Factorial with integer
  3. int calculateFactorial_integer(int n) {
  4. if (n < 0) {
  5. } else if (n == 0 || n == 1) {
  6. return 1;
  7. } else {
  8. int result = 1;
  9. for (int i = 2; i <= n; ++i) {
  10. result *= i;
  11. }
  12. return result;
  13. }
  14. return 0;
  15. }