**Q- Implement 2 variable XOR gate using NAND only in minimum number of gates.**

F= x XOR y = x’y+xy’ = x’y+xy’+xx’+yy’ = (x+y) (x’+y’)

Now we need to implement this circuit using NAND gates

F= (x+y)(xy)’ = x. (xy)’ + y. (xy)’

Take compliment

F’= ( x. (xy)’ + y. (xy)’ )’ = (x. (xy)’)’. (y. (xy)’)

Take compliment again

F=( (x. (xy)’)’. (y. (xy)’) )’

Now we can implement this using NAND gates

So we get that we need minimum of 4 NAND gates to implement XOR gate and if we are to implement XNOR gate then we’ll use 5 NAND gates with 5^{th} gate used as inverter and placed in-front of 4^{th} NAND gate in above circuit.