2^X-2 <-memorize it
i need a network with 30 hosts. 2^5 = 32. 32-2 = 30. X is how many bits you need for you host id.
2^X tells you how many binary numbers can be represented by X bits. The first and last host ids cannot be used because the first is the network id and the last is the broadcast address.