【入门】编程求1*2*3*...*n 求答案
【入门】编程求1*2*3*...*n 求答案
#include <iostream> #include <cmath> int main( void ) { unsigned n = 5; std::cout << n << "! = " << std::tgamma(n+1) << '\n'; long double m = 5.2; std::cout << m << "! = " << std::tgamma(m+1) << '\n'; }
#include <iostream> unsigned long long foo( unsigned n ) { unsigned long long result = 1; for( ; n!=0; --n ) result *= n; return result; } int main( void ) { unsigned n = 5; std::cout << n << "! = " << foo(n) << '\n'; }