Given a prefix Y, it's easy to calculate the corresponding netmask: Put Y times a set bit, and then fill up "to the right" with zeros until one has 32 bits (IPv4) in total.
Example:
Prefix 24, thus netmask 11111111 11111111 11111111 00000000 or 255.255.255.0.
Can there be a netmask with a different bit pattern, such as
00000000 11111111 00000000 11111111(0.255.0.255)00000000 11111111 11111111 11111111(0.255.255.255)11111111 11111111 11111111 00000001(255.255.255.1)
Specifying a "prefix" obviously wouldn't work for these cases.
(I'm pretty sure the answer is "NO", but I'm writing some network code, and this needs to work in all possible cases, so I want to be 101% sure.)