题目描述
求 n!n!,也就是 1\times2\times3\dots\times n1×2×3⋯×n。
挑战:尝试不使用循环语句(for、while)完成这个任务。
输入格式
第一行输入一个正整数 nn。
输出格式
输出一个正整数,表示 n!n!。
输入输出样例
输入 #1复制
3
输出 #1复制
6
说明/提示
数据保证,1 \leq n\le121≤n≤12。
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int Recursion(int n)
{
if(n <= 1)
return 1;
else
return n*=Recursion(n-1);
}
int main()
{
int n;
cin >> n;
cout << Recursion(n);
return 0;
}