The S&W model numbering system began in 1957. When the system started, the numbers 10-19 were assigned to K frame models (medium size), 20-29 to N frames (large), 30-38 to I or J frames (small; all I frames were later replaced by equivalent J frames), and the number 39 was assigned to the 9mm DA/SA semi-automatic pistol.
Subsequent model numbers were assigned in a semi-consecutive fashion, but it's seemingly haphazard because not all model numbers were used, some guns had extremely limited production (e.g. the Model 44), and semi-autos are mixed with revolvers. 40-59 are a total mess; the Model 60 and Models 63 thru 67 are stainless steel versions of earlier models.
In the 1980s, S&W introduced a 3-digit system for new models, in which the first number indicated the gun's finish and the 2nd and 3rd numbers usually matched an earlier and similar model. 5xx indicates blued carbon steel frame, 6xx indicates stainless steel, and 2xx or 3xx indicates Scandium/Aluminum frame. However, there are enough exceptions within the system to thoroughly confuse things, and S&W introduced ANOTHER numbering system for the so-called 3rd-generation metal-frame centerfire automatics. (It's so complex won't even TRY to describe it here.)
This became so confusing that product planners at S&W apparently threw up their hands in the mid 1990s, giving some newer pistols their own model numbering systems (e.g. the SW99 and Sigma series), and introducing newer models that only have names (the M&P, the Bodyguard .38, and the Bodyguard .380)!
How does one remember it all? Basically, one doesn't.
Figure out which features you like and concentrate on remembering THOSE numbers. Just remember that the 3-digit system generally describes similar guns; e.g. the M40 is similar to the M340 and M640.