← Back to challenges

Combinatorial Exploration

JavaScriptHardrecursionhigher_order_functionsmath

Instructions

Given a known number of unique items, how many ways could we arrange them in a row?

Create a function that takes an integer n and returns the number of digits of the number of possible permutations for n unique items. For instance, 5 unique items could be arranged in 120 unique ways. 120 has 3 digits, hence the integer 3 is returned.

Examples

noPermsDigits(0) ➞ 1

noPermsDigits(1) ➞ 1

noPermsDigits(5) ➞ 3

noPermsDigits(8) ➞ 5

Notes

This challenge requires some understanding of combinatorics.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: All Occurrences of an Element in an Array