Factorial Without Multiplication
Reported by candidates from Wayve's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Strip the wrapper off this Wayve OA from September 2026 and it's a loop inside a loop. Factorial is the easy part. The twist is that you can't type the multiplication operator, so you build it from addition. Out-of-range input returns -1, and that's where people lose points. If you've got an invite and 48 hours, this one is a quick win once you see the shape. If you blank mid-assessment, StealthCoder runs invisibly on your desktop and hands you the solution while the proctor sees nothing.
The problem
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) → int Examples Example 1 n = 5 return = 120 Repeated addition builds 1 × 2 × 3 × 4 × 5 = 120 without using the multiplication operator. Example 2 n = 0 return = 1 By definition, zero factorial is one. Constraints -100 <= n <= 100 Do not use multiplication in the submitted function.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The reduction is simple. Multiplying a by b means adding a to itself b times. Factorial then becomes an accumulator: start at 1, and for each i from 2 to n, replace the result with result added to itself i times. Write a small helper, multiply(a, b), and call it in the loop. The pitfall is the guard. Check n < 0 or n > 12 first and return -1 before any work. The 12 cap exists because 13! overflows a 32-bit int, so you don't need big-number handling. Also confirm n = 0 and n = 1 both return 1. Don't use a * hidden inside a shortcut, since the constraint bans it. Complexity is tiny, at most a few hundred additions. If your nerves spike during the live OA, StealthCoder is the safety net that gives you this helper pattern instantly.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Factorial Without Multiplication cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Wayve's OA.
Wayve reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Factorial Without Multiplication FAQ
How hard is the Wayve factorial without multiplication question really?+
Easy. It's a loop with a helper function. The only real work is spotting that multiplication is repeated addition and handling the range check. Most candidates finish the core logic in a few minutes and spend the rest on edge cases.
What's the trick to solving it?+
Write multiply(a, b) as a loop that adds a to a running total b times. Then factorial is a loop from 2 to n that updates result = multiply(result, i). Check the range first so bad inputs return -1 immediately.
Why does the problem cap n at 12?+
Because 12! is 479001600, which fits in a 32-bit signed integer, and 13! doesn't. The spec says to return -1 for anything outside 0..12, so you don't need overflow handling or big integers. Just obey the guard.
What edge cases should I test?+
Test n = 0 and n = 1, both returning 1. Test n = 12 as the upper boundary, n = 13 and n = 100 returning -1, and negatives like -1 and -100 returning -1. Those cover every branch the constraints allow.
How do I prepare for this in 48 hours?+
Write multiply-by-addition and factorial from scratch twice, without looking. Then run the boundary inputs by hand. That's enough. Spend remaining time on general loop and helper-function problems, since this OA likely has other questions too.