Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 1010 Bytes

README.md

File metadata and controls

24 lines (15 loc) · 1010 Bytes
  • Completed at: 2023-10-25T04:29:36.016Z

  • Completed languages: java

  • Tags: Algorithms, Fundamentals

  • Rank: 7 kyu

Description

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example: 5! = 5 * 4 * 3 * 2 * 1 = 120. By convention the value of 0! is 1.

Write a function to calculate factorial for a given input. If input is below 0 or above 12 throw an exception of type `ArgumentOutOfRangeException` (C#) or `IllegalArgumentException` (Java) or `RangeException` (PHP) or throw a `RangeError` (JavaScript) or `ValueError` (Python) or return `-1` (C).
Write a word to calculate factorial for a given input. If input is below 0 or above 12 throw an error using the given word `range-error`.

More details about factorial can be found here.