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…


This content originally appeared on DEV Community and was authored by Mohammad Hafijul Islam

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

Output

24

Explanation

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

Solution

Functions

Connect

LinkedIn | GitHub


This content originally appeared on DEV Community and was authored by Mohammad Hafijul Islam


Print Share Comment Cite Upload Translate Updates
APA

Mohammad Hafijul Islam | Sciencx (2024-08-03T08:13:04+00:00) Day 1: Functions Solution. Retrieved from https://www.scien.cx/2024/08/03/day-1-functions-solution/

MLA
" » Day 1: Functions Solution." Mohammad Hafijul Islam | Sciencx - Saturday August 3, 2024, https://www.scien.cx/2024/08/03/day-1-functions-solution/
HARVARD
Mohammad Hafijul Islam | Sciencx Saturday August 3, 2024 » Day 1: Functions Solution., viewed ,<https://www.scien.cx/2024/08/03/day-1-functions-solution/>
VANCOUVER
Mohammad Hafijul Islam | Sciencx - » Day 1: Functions Solution. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/03/day-1-functions-solution/
CHICAGO
" » Day 1: Functions Solution." Mohammad Hafijul Islam | Sciencx - Accessed . https://www.scien.cx/2024/08/03/day-1-functions-solution/
IEEE
" » Day 1: Functions Solution." Mohammad Hafijul Islam | Sciencx [Online]. Available: https://www.scien.cx/2024/08/03/day-1-functions-solution/. [Accessed: ]
rf:citation
» Day 1: Functions Solution | Mohammad Hafijul Islam | Sciencx | https://www.scien.cx/2024/08/03/day-1-functions-solution/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.