DEV Community

Cover image for Day 1: Functions Solution
Mohammad Hafijul Islam
Mohammad Hafijul Islam

Posted on

Day 1: Functions Solution

Task

Implement a factorial function with one parameter: an integer, n. It must return the value of n! (i.e., n factorial).

Constraints

  • 1 ≤ n ≤ 10

Input Format

Locked stub code in the editor reads a single integer, n, from stdin and passes it to a factorial function.

Output Format

The function must return the value of n!.

Sample

Input

4
Enter fullscreen mode Exit fullscreen mode

Output

24
Enter fullscreen mode Exit fullscreen mode

Explanation

We return the value of 4! = 4x3x2x1 = 24.

Solution

Functions

Connect

LinkedIn | GitHub

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay