Instead of subnet, use ipcalc.
# ipcalc -mpnb 10.0.0.0 255.255.240.0
NETMASK=255.255.240.0
PREFIX=20
BROADCAST=10.0.15.255
NETWORK=10.0.0.0
# ipcalc -mpnb 10.0.0.0 255.255.255.0
NETMASK=255.255.255.0
PREFIX=24
BROADCAST=10.0.0.255
NETWORK=10.0.0.0
(The article title probably confused everyone except me.
subnet is a perl script I wrote which basically does the same thing, although it has a few additional features.
ipcalc can be expected on practically any modern RedHat flavored distro these days, while
subnet is less frequently available.)