logo

Back to questions

Factorial Formula [Microsoft Python Interview Question]

Easy

Given a number nn, write a formula that returns n!n!.

In case you forgot the factorial formula, n!=n(n1)(n2).....21 n! = n * (n-1) * (n-2) * ..... 2 * 1.

For example, 5!=54321=1205! = 5 * 4 * 3 * 2 * 1 = 120 so we'd return 120.

Assume is nn is a non-negative integer.

p.s. if this problem seems too trivial, try the follow-up Microsoft interview problem Factorial Trailing Zeroes

Python