Factorial Cpp

Shared by: this

cpp

1
#include <iostream>
2

3

4
using namespace std;
5

6
int factorial(int number){
7
    if (number == 1){
8
        return number;
9
    };
10
    int factorialSum  = number * factorial(number - 1);
11
    return factorialSum;
12
}
13

14
int main() {
15
    int factorialOf = factorial(7);
16
    cout << factorialOf;
17
    return 0;
18
}