102730: [AtCoder]ABC273 A - A Recursive Function

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $100$ points

Problem Statement

A function $f(x)$ defined for non-negative integer $x$ satisfies the following conditions:

  • $f(0) = 1$;
  • $f(k) = k \times f(k-1)$ for all positive integers $k$.

Find $f(N)$.

Constraints

  • $N$ is an integer such that $0 \le N \le 10$.

Input

The input is given from Standard Input in the following format:

$N$

Output

Print the answer as an integer.


Sample Input 1

2

Sample Output 1

2

We have $f(2) = 2 \times f(1) = 2 \times 1 \times f(0) = 2 \times 1 \times 1 = 2$.


Sample Input 2

3

Sample Output 2

6

We have $f(3) = 3 \times f(2) = 3 \times 2 = 6$.


Sample Input 3

0

Sample Output 3

1

Sample Input 4

10

Sample Output 4

3628800

Input

题意翻译

求 $n$ 的阶乘。$0\le n\le 10$。 特别的:$0$ 的阶乘为 $1$。

Output

分数:100分

问题描述

定义在非负整数上的函数$f(x)$满足以下条件:

  • $f(0) = 1$;
  • 对于所有的正整数$k$,$f(k) = k \times f(k-1)$。

求$f(N)$。

限制条件

  • $N$是一个整数,满足$0 \le N \le 10$。

输入

从标准输入按以下格式给出输入:

$N$

输出

将答案输出为一个整数。


样例输入1

2

样例输出1

2

我们有$f(2) = 2 \times f(1) = 2 \times 1 \times f(0) = 2 \times 1 \times 1 = 2$。


样例输入2

3

样例输出2

6

我们有$f(3) = 3 \times f(2) = 3 \times 2 = 6$。


样例输入3

0

样例输出3

1

样例输入4

10

样例输出4

3628800

加入题单

算法标签: