NAND Bricks

How to build an AND gate from NAND gates

An AND gate takes two NAND gates. NAND means "not AND", so you take the NAND of A and B and then flip it with a second NAND wired as a NOT gate. The result is 1 only when both A and B are 1.

Inputs
1NAND2NANDA1B11Q
Click the inputs to try every combination. Green wires carry 1 and red wires carry 0. The small numbers match the steps below.
Open this circuit in NAND BricksLoads it as a new board with its truth table, ready to run.

The formula

Q = NOT(NAND(A, B)) = NAND(N, N), where N = NAND(A, B)

How it works

The name gives it away: NAND is AND followed by NOT. To get plain AND back, add another NOT at the end. Two NOTs cancel, leaving AND.

The second gate is the NOT gate from the previous guide: a NAND with both inputs tied to the first gate's output.

Gate by gate

  1. Computes NAND(A, B). This is 0 only when A and B are both 1.
  2. A NOT gate. Flips the first result, so the output is 1 only when A and B are both 1.

Truth table

ABQ
000
010
100
111

Why 2 NAND gates?

Two is the fewest possible. One NAND on its own can only make NAND or NOT, so AND needs a second gate. We checked this by trying every possible circuit with fewer gates.

Where it's used

AND is the "both must be true" gate. It masks bits, enables a signal only when a condition holds, and makes the carry bit in a half adder.