mirror of
https://bitbucket.org/Mattrixwv/my-classes.git
synced 2025-12-06 18:23:57 -05:00
Added function to find factorial of number
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user