How to subnet an IPv4 /24

The total number of IP addresses in a subnet is a power of two. So that's:
1, 2, 4, 8, 16, ... etc.

The first IP address in a subnet is a multiple (0, 1, 2, 3 ...) of the
number of IP addresses in the subnet.

'x' in netmask '255.255.255.x' is 256 - number of IP addresses in the
subnet.

In slash-notation, the netmask is '/y', where y = 32 - n, and 2ⁿ is the
number of addresses in the subnet.

So if we want 4 addresses in our subnet, the first address in this subnet is
either 0 or 4 or 8 or 12 or ... etc.
And 'x' in netmask '255.255.255.x' is: 256 - 4 = 252. So the netmask is:
'255.255.255.252'.
4 = 2², so n = 2 and y is 32 - 2 = 30. The slash-notation netmask is
therefore: '/30'.