Answers for "math expressions"

C++
0

math expressions

#include<iostream>
#include<cmath>
#include<iomanip>

unsigned long long factorial(unsigned long long );

unsigned long long factorial(unsigned long long num){

    if(num<=0)
        return 1;

    return num * factorial(num-1);
}

int main()
{
    std::cout<<"Enter number\t"<<std::endl;
    unsigned long long num,number;
    std::cin >> num;
    std::cout<<std::fixed<<std::setprecision(9)<<factorial(num)/pow(num,num)<<std::endl;
    
}
Posted by: Guest on December-28-2020

Browse Popular Code Answers by Language