Added function to find factorial of number

This commit is contained in:
2021-06-01 15:16:07 -04:00
parent b035dcfaed
commit 190d92da47
2 changed files with 41 additions and 2 deletions

View File

@@ -576,6 +576,15 @@ std::vector<std::string> split(std::string str, char delimiter){
return splitStrings;
}
//Return the factorial of the number passed in
template <class T>
T factorial(T num){
T fact = 1;
for(T cnt = 1;cnt <= num;++cnt){
fact *= cnt;
}
return fact;
}
}