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.
- 2NAND gates
- Yesfewest possible
- 2inputs
- 1output
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
- Computes NAND(A, B). This is 0 only when A and B are both 1.
- A NOT gate. Flips the first result, so the output is 1 only when A and B are both 1.
Truth table
| A | B | Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
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.