Clipper is quite correct; each airline is given its own identifier. Pan Am was -21 and it ran through all the numbers, then letters and numbers (e.g. Thai, -D7), then numbers and letters (e.g. -8E, Asiana) and more recently, two letters. This is actually very useful in identifying the first operator of an aircraft, as it will carry this code through its life; e.g. a few of the Olympic 747s were -212s, which identifies them as being ex-Singapore Airlines.
As to options and engines, this doesn't actually have a bearing on the number. For example, JAL was always a PW user until it got its -400s, but still kept its -46 identifier.