Answers for "WAP to calculate factorial and to computer the factors of a given no i)using recursion ii)using iteration."

C++
8

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
Posted by: Guest on July-09-2020

Code answers related to "WAP to calculate factorial and to computer the factors of a given no i)using recursion ii)using iteration."

Browse Popular Code Answers by Language