A - A Recursive Function
cpatcoderjust dodiff gray
最終更新日
問題
https://atcoder.jp/contests/abc273/tasks/abc273_a (新しいタブで開く)
問題文
f(x)=1 if x=0 else x×f(x−1)
f(N) は?
制約
- 1≤N≤10
サンプル
I/O 1
2
2
I/O 2
3
6
I/O 3
0
1
I/O 4
10
3628800
考察
見るからに f(N)=N! なので、やるだけ。
コード
https://atcoder.jp/contests/abc273/submissions/35661996 (新しいタブで開く)
int main() {
int n;
cin >> n;
int ans = 1;
rep(i, n) ans *= (i + 1);
cout << ans << endl;
return 0;
}