#202. 递归实现阶乘计算

    ID: 202 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp5递归数学基础

递归实现阶乘计算

Recursive Factorial

Background

Congcong has recently been learning about the concept of factorials in mathematics. He wants to know how to calculate the factorial of a number using programming, specifically requiring a recursive approach.

Problem Description

Given an integer nn of 11 or more, return the factorial of nn, which is n×(n1)×(n2)××1n \times (n-1) \times (n-2) \times \dots \times 1. Compute the result recursively (without loops).

Input Format

Input is given from standard input in the following format.

An integer nn.

Output Format

Output is printed to standard output in the following format.

The factorial of nn.

Sample

1
1
2
2
3
6

Constraints

Time limit: 1 second, Memory limit: 1024KB for each test case.