All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

What is factorial complexity?

Post cover: What is factorial complexity?
This content has been automatically translated from Ukrainian.
Factorial complexity is a situation where the number of options or combinations grows like the factorial of the number of elements. In other words, for n elements, the possible permutations are n!n!n! (n factorial), which quickly becomes a huge number even for small n.
This phenomenon is often encountered in combinatorics, planning, and exhaustive algorithms. For example, the permutations of 5 elements are 120 options, while for 10 elements, there are already 3,628,800.
Real-life examples:
  • Permutations of tasks or routes – planning delivery routes or tasks in a project.
  • Playing chess or puzzles – the number of possible sequences of moves grows extremely quickly.
  • Cryptography – guessing combinations or passwords through exhaustive search.
A simple Ruby code to demonstrate factorial complexity:
def factorial(n)
  (1..n).reduce(1, :*)
end

(1..10).each do |i|
  puts "n=#{i} - #{factorial(i)} options"
end
Result:
n=1 - 1 options
n=2 - 2 options
n=3 - 6 options
n=4 - 24 options
n=5 - 120 options
n=6 - 720 options
n=7 - 5040 options
n=8 - 40320 options
n=9 - 362880 options
n=10 - 3628800 options
=> 1..10
This example shows why factorial complexity quickly complicates the task and makes direct enumeration of options practically impossible.

This post doesn't have any additions from the author yet.

What is combinatorial explosion?
Jul 28, '25 11:50

What is combinatorial explosion?

What is a brain stack?
Jul 28, '25 19:37

What is a brain stack?

What is integer overflow?
Aug 15, '25 08:28

What is integer overflow?

What is a HAR file (HTTP Archive)?
Aug 25, '25 18:23

What is a HAR file (HTTP Archive)?

What is Bubble Sort (algorithm explanation)?
Sep 16, '25 18:42

What is Bubble Sort (algorithm explanation)?

What is exponential growth?
Sep 16, '25 18:57

What is exponential growth?

What is NP-complexity?
Sep 16, '25 19:31

What is NP-complexity?

Offset vs Cursor Pagination in Rails: what to choose and why
Sep 24, '25 15:22

Offset vs Cursor Pagination in Rails: what to choose and why

What is Row Security in PostgreSQL and why is it important for Rails developers
Oct 4, '25 19:06

What is Row Security in PostgreSQL and why is it important for Rails developers

What is ivar in Ruby / Rails?
Oct 19, '25 20:12

What is ivar in Ruby / Rails?

Main methods of authentication in API
Oct 19, '25 20:26

Main methods of authentication in API

What are the differences between OAuth 1 and OAuth 2
Oct 19, '25 20:34

What are the differences between OAuth 1 and OAuth 2