index | submit | rank | book

factorial – Factorial of a number

Write a program that computes the factorial of a number n, or simply n!.

We can recursively define the factorial of a number as:

In symbolic terms:

By the above definition, the factorial of 4 is 24

Input and Output

Input will contain several lines with a single integer n where 0 ≤ n ≤ 12. Output should contain a line with the factorial of n.

Example input


Example output


The factorial function

Your program should contain a factorial function that takes an integer and returns an integer. Please refer to the information for your chosen language:


try first: good oddeven factorial1

try next: power

index | submit | rank | book

Copyright © 2020-2021 Rudy Matela
All rights reserved