It looks complicated because over the last century the Underground has used several different numbering schmes, but has not renumbered existing stock when a new scheme is introduced.
1. In about 1930 the UERL renumbered the stock on all its lines into one scheme:
District stock was 1xxx for unrefurbished wooden boded stock, and 4xxx and 8xxx for the more modern stock (motor and trailer respectively).
Tube stock was 3xxx, 5xxx and 7xxx for motor, control trailer and trailer respectively - some tube stock control trailers were later converted to trailers and numbered in the 75xxx series
When London Transport was formed in 1933, former Metropolitan stock (including GN&C) was numbered in the 2xxx, 6xxx and 9xxx ranges, again for motor, control trailer and trailer respectively, with hauled stock retaining their 3-digit MR numbers.
2. Starting with the 1935 tube stock and the Metadyne (O and P) surface stock, five digit numbers were allocated:
10xxx, 11xxx and 12xxx for tube stock, and 13xxx, 14xxx for surface stock - trailers having a zero prefix (eg 012345 or 014567) (note that the contempoary Q stock motor cars, built to run with older stock, were given 4-digit numbers in the old scheme, but the trailers were intended for conversion at a later date and numbered in the 013xxx and 014xxx ranges
R stock was numbered in the 2xxxx range (this included many converted Q stock cars)
1949 stock was numbered in the 3xxxx range
1956 stock was originally numbered in the 4xxxx range
Converted O and P motor coaches (but not the trailers) stock had 40,000 added to their numbers, so they were in the 53xxx and 54xxx range
A number of "standard" stock trailers were converted to run with 1938 stock, and renumbered from the 7xxx range to the 70xxx range
1938 stock conveerted for use in 9-car trains (mainly the re-positioning of guiards controls) were renumbered in the 9xxxx range
3. From 1959, a new scheme was introduced, using 4-digit numbers (with two exceptions). This was used for A,C and D surface stock and all tube stocks from 1959 to 1983 (except 1973). Unusually, the 1956 stock was renumbered from the 4xxxx range into this scheme
1xxx Tube stock DM (until 1962)
2xxx Tube stock trailer (until 1962)
9xxx Tube stock NDM (until 1962)
3xxx (from 1967) - Tube stock DM and UNDM
4xxx (from 1967) - Tube stock trailers: a handful of surviving Q stock had to be renumbered to make way for these)
5xxx Surface stock motors (A and C stock)
6xxx Surface stock trailers (A and C stock)
7xxx D stock motors
8xxx D stock NDMs
17xxx D stock trailers (that's the first exception)
The second exception was the 1973 stock on the Piccadilly Line which was given 3-digit numbers, rather than in the 3xxx and 4xxx range - probably because there were not enough numbers left for such a large fleet - but the less numerous fleet of 1983 stock was numbered in that range.
4. New Tube stock in the 1990s were originally all to have been numbered in the 9xxxx range - 1992 stock in the 90xxx to 94xxx range, 1995 stock in the 95xxx range, and 1996 stock in the 96xxx range. However, the 1995 stock has instead been numbered in the 5xxxx range, this has allowed the second digit, instead of the third, to identify the type of car, leaving three digits for the individual unit (there being more than 100 trains in the fleet). Waterloo and City stock have kept their BR TOPS carriage numbers in the 6xxxx range (signifying a power car)
5. From 2000 we are back to a scheme rather similar to scheme 2 above. 2009 stock is numbered in the 1xxxx range, S stock in the 2xxxx range, and 2024 tube stock in the 3xxxx range - in each case with the second digit identifying the position of the vehicle in the unit