Calcular el factorial


Submit solution

Points: 10
Time limit: 5.0s
Memory limit: 256M

Author:
Problem types
Allowed languages
C#, Go, Java

El factorial d'un nombre enter \(N\) s'escriu com a \(N!\) i es calcula multiplicant el nombre actual pel seu anterior fins a arribar a un. Per exemple, \(3! = 3\) x \(2\) x \(1\).

Cal tenir una excepció: \(0! = 1\).

Input Format

L'entrada consisteix en un únic nombre enter.

Constraints

  • \(N >= 0\)

Output Format

S'imprimirà el resultat de calcular el factorial.

Sample Input 0

3

Sample Output 0

6

Sample Input 1

4

Sample Output 1

24

Sample Input 2

9

Sample Output 2

362880

Sample Input 3

2

Sample Output 3

2

Sample Input 4

1

Sample Output 4

1

Sample Input 5

0

Sample Output 5

1

Autoria: Fernando Porrino Serrano

CC BY-NC-SA 4.0