Byte Rex
Boolean Function Counter Calculator

Boolean Function Counting

Field: Digital Logic / Computer Engineering

Written and maintained by the PhDino author · Last reviewed 21 September 2026 · Checked against 2 independent reference calculations · how PhDino checks its numbers

How fast the space of possible logic functions explodes as the number of input variables grows.

A truth table for n boolean variables has exactly 2ⁿ rows, since each variable independently doubles the number of possible input combinations. That part is intuitive. What's much less intuitive is how many distinct boolean functions exist for those n variables: since each row of the truth table can independently be assigned a 0 or 1 output, the number of distinct possible functions is 2 raised to the power of the number of rows — 2^(2ⁿ).

That double exponential is genuinely explosive: 2 variables already allow 16 possible functions, 3 variables allow 256, and 4 variables allow 65,536 — despite the truth table itself only growing linearly in row count (4, 8, 16 rows respectively). This is the deeper reason simplification tools like Karnaugh maps and the Quine-McCluskey algorithm matter: the space of things a circuit could compute grows far faster than the table describing any one of them.

Key formula

Truth table rows = 2ⁿ
Possible distinct functions = 2^(2ⁿ)
No. 086 / 092Digital Logic / Computer Engineering
Boolean Function Counter
Presented by Byte Rex · Digital Logic & Computing
No. 086 / 092Boolean Function Counter
Truth table rows = 2ⁿ
Possible distinct functions = 2^(2ⁿ)
Worked example
Number of Variables: 3
→ Truth Table Rows: 8
Checked: this exact example is one of the automated reference tests, its answer worked out independently of the calculator.
phdino.com/calc/boolean-function-counter

How to use the Boolean Function Counter calculator

Enter a number of input variables and the calculator gives two counts: the rows of the truth table, 2ⁿ, and the number of different Boolean functions those inputs can have, which is 2 raised to the number of rows. A function here means a complete truth table: one output bit chosen for every row.

Use it to get a feel for how quickly logic grows: how many cases an exhaustive test must cover, how many bits a lookup table needs, or why nobody designs logic by browsing a list of every possible function. It takes one to five inputs, because beyond that the second count becomes astronomically large.

Number of Variables
The number of independent one-bit inputs. Count every bit of a multi-bit signal separately: two 2-bit numbers are four inputs.

Worked example: a 4-input lookup table

An FPGA builds its logic from small lookup tables: a tiny memory addressed by the inputs, whose stored bits are the outputs. How many entries does a 4-input table hold, and how many different functions can it be set to?

You enterValue
Number of Variables4
The calculator returnsValue
Truth Table Rows16
Possible Boolean Functions65,536

Worked by hand:

  1. Rows. Each input is 0 or 1, so 4 inputs give 2 × 2 × 2 × 2 = 16 combinations, one row of the truth table each.
  2. Storage. The lookup table keeps one output bit per row, so it holds 16 bits.
  3. Functions. Each of those 16 bits can be 0 or 1 independently, which gives 2^16 = 65,536 different settings, and every setting is a different function.

One 4-input lookup table can therefore act as any of 65,536 functions, from AND and XOR to ones with no name at all, just by loading different bits. That flexibility is why FPGAs use tables rather than fixed gates. Add one input and the table doubles to 32 bits, but the number of functions squares: five inputs allow 4,294,967,296 of them.

Reading the result: rows grow, functions explode

The two numbers grow at very different rates. Rows double with each input, which stays manageable: 32 rows for five inputs still fits on one page. The function count is two raised to the row count, so it squares with every input, and that is what makes exhaustive approaches break down.

  • For testing: checking a block against every input combination means one test per row, 2ⁿ cases. A block with 32 inputs would need more than four billion, which is why real designs are tested with chosen vectors and formal tools rather than brute force.
  • For storage: a lookup table, ROM or memory used as logic needs one bit per row for each output. Ten inputs mean 1,024 bits per output.
  • For design: with so many possible functions, logic is described by what it must do, an equation or the truth table of the one function you need, and then simplified with Karnaugh maps or software. Nobody picks it from a list.
  • Different circuits can produce the same function. The count is of distinct truth tables, not of gate arrangements, which are unlimited.

Notes & limitations

  • This counts every mathematically possible function of n inputs, including ones with no simpler circuit realization and ones that are constant, trivial, or practically useless — it's a statement about the size of the function space, not about how many of those functions are actually useful.
  • This is why minimization matters practically: among the enormous space of possible functions, the one a real circuit needs to implement can very often be built from far fewer gates than a naive one-gate-per-truth-table-row implementation would require.

Common mistakes

  • Confusing the two counts. Rows are input combinations; functions are complete columns of outputs. A 3-input truth table has 8 rows but 256 possible functions.
  • Writing 2ⁿ for the number of functions. The exponent is itself 2ⁿ, so the right expression is 2 to the power 2ⁿ.
  • Counting a multi-bit input as one variable. An 8-bit value is eight inputs, so a function of a single byte already has 256 rows.
  • Expecting the count to say how many gates a function needs. It tells you how many functions exist, not how hard any one of them is to build, and most of them need far more gates than the familiar ones.
  • Forgetting that the total includes the trivial cases: the constant 0 and constant 1 outputs, and every function that ignores some of its inputs.

Frequently asked questions

How many functions of two variables are there?

Sixteen. Two inputs give four rows, and 2⁴ = 16. They include AND, OR, NAND, NOR, XOR and XNOR, the two constants, each input and its complement, and four less often named ones such as "A and not B".

Why do FPGA lookup tables usually have four to six inputs?

Because the storage doubles with every extra input while a great deal of real logic needs only a few inputs at a time. A 6-input table already holds 64 bits; much larger tables would spend memory on functions that are rarely needed.

Can every Boolean function be built from NAND gates alone?

Yes. NAND is functionally complete: NOT, AND and OR can each be made from NAND gates, so any of the counted functions can be built from them. The same is true of NOR.

Is the number of functions the same as the number of circuits?

No. Many different circuits implement the same function, and simplifying a design means finding a smaller circuit with the same truth table. The calculator counts truth tables, not circuits.

Further reading

PhDino earns a commission on qualifying purchases made through this link, at no extra cost to you.

Code: The Hidden Language of Computer Hardware and Software by Charles Petzold — Builds from switches and logic gates up to a working computer, one clear step at a time. (Bookshop.org UK, UK delivery only)

→ The full PhDino bookshelf on Bookshop.org (UK delivery only)

Educational tool — not a substitute for a licensed engineer or the official code text.