code_junkie

programmatically find number of hosts in a Netmask

Nov 11th, 2011
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.12 KB | None | 0 0
  1. >>> def number_of_hosts(n):
  2. ... return 2 ** (32 - n)
  3. ...
  4. >>> number_of_hosts(32)
  5. 1
  6. >>> number_of_hosts(30)
  7. 4
Add Comment
Please, Sign In to add comment