Factorial Without Multiplication
Problem statement
Return n! without using the multiplication operator. Implement multiplication through repeated addition. Return -1 when n is outside the supported range 0..12.
Function
factorialWithoutMultiplication(n: int) → intExamples
Example 1
n = 5return = 120Repeated addition builds 1 × 2 × 3 × 4 × 5 = 120 without using the multiplication operator.
Example 2
n = 0return = 1By definition, zero factorial is one.
Constraints
-100 <= n <= 100- Do not use multiplication in the submitted function.