Skip to content

Instantly share code, notes, and snippets.

@kaubu
Created October 15, 2024 07:39
Show Gist options
  • Save kaubu/3bab9b0515506bec1aa8a35fa597ede6 to your computer and use it in GitHub Desktop.
Save kaubu/3bab9b0515506bec1aa8a35fa597ede6 to your computer and use it in GitHub Desktop.
Given a prefix notation, calculate the possible number of IP addresses in a subnet
def calc_assignable(prefix):
import math
print(f"{int(math.pow(2, 32 - prefix) - 2):,}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment