Horje
built in factorial function in c++ Code Example
c++ factorial
#include <cmath>

int fact(int n){
    return std::tgamma(n + 1);  
}    
// for n = 5 -> 5 * 4 * 3 * 2 = 120 
//tgamma performas factorial with n - 1 -> hence we use n + 1
built in factorial function in c++
int factorial(int n)
{
  return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;
}




Cpp

Related
c++ vs g++ Code Example c++ vs g++ Code Example
how to print a text in c++ Code Example how to print a text in c++ Code Example
std::iomanip c++ Code Example std::iomanip c++ Code Example
how to delete a node c++ Code Example how to delete a node c++ Code Example
system cpp Code Example system cpp Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11