Constants
32 bits per subnet address range
2 reserved addresses (router and broadcast)
Target
Find the remainder between CIDR mask and total available range. Exponent 2 (bit depth) by the remainder and remove reserved addresses.
Algorithm : (2^(32 - #CIDR))-2
Examples
CIDR /30 = (2^(32 - 30))-2 = 2 available hosts
CIDR /24 = (2^(32 - 24))-2 = 254 available hosts
CIDR /16 = (2^(32 - 16))-2 = 65534 available hosts