Asa's Website

A - A Recursive Function

cpatcoderjust dodiff gray

最終更新日

Table of Contents

Loading...

問題

https://atcoder.jp/contests/abc273/tasks/abc273_a

問題文

f(x)=1 if x=0 else x×f(x1)f(x) = 1 \text{ if } x = 0 \text{ else } x \times f(x-1)

f(N)f(N) は?

制約

サンプル

I/O 1

2
2

I/O 2

3
6

I/O 3

0
1

I/O 4

10
3628800

考察

見るからに f(N)=N!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; }