题解 | #n的阶乘#

n的阶乘

http://www.nowcoder.com/practice/97be22ee50b14cccad2787998ca628c8

【C++】已通过

#include<algorithm>
using namespace std;
long long int f(int n) {
	long long int res = 1;
	for (int i = 1; i <= n; i++) {
		res *= i;
	}
	return res;
}
int main() {
	int n;
	while (cin >> n) {
		cout << f(n) << endl;
	}
	return 0;
}
全部评论

相关推荐

04-22 15:13
已编辑
Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务